题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-19 07:15:39

[简答题]下列给定程序中,函数fun的功能是:传入一个整数m,计算如下公式的值。
t=1/2-1/3-…-1/m
例如,若输入5,则应输出-0.283333。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
double fun(int m)

double t=1.0;
int i;
for(i=2;i<=m;i++)
/*******************found***********/
t=1.0-1/i;
/*******found**********/

void main( )

int m;
printf("/nPlease enter 1 integer number:/n");
scanf("%d",&m);
printf("/n/nThe result is%lf/n",
fun(m));

更多"下列给定程序中,函数fun的功能是:传入一个整数m,计算如下公式的值。"的相关试题:

[填空题]下列给定程序中,函数fun( )的功能是:传入一个整数m,计算如下公式的值。
t=1/2-1/3-…-1/m
例如,若输入5,则应输出-0.283333。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
double fun(int m)

double t=l.0;
int i;
for (i=2; i<=m; i++)
/*************found**************/
t=l.0-1/i;
/*************found**************/

main ( )
int m;
clrscr ( );
printf ("/nPlease enter 1 integer numbers
: In");
scanf ("%d", &m);
printf("/n/nThe result is %lfln",
fun (m));

[填空题]由N个有序整数组成的数列已放在一维数组中,下列给定程序函数fun的功能是:利用折半查找法查找整数m在数组中的位置。若找到,返回其下标值;否则,返回-1。
折半查找的基本算法是:每次查找前先确定数组中待查的范围low和high(low<high),然后用m与中间位置(mid)上元素的值进行比较。如果m的值大于中间位置元素的值,则下一次的查找范围落在中间位置之后的元素中;反之,下一次的查找范围落在中间位置之前的元素中,直到low>high,查找结束。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 10
/**********found**********/
void fun(int a[],int m)
int low=0,high=N-1,mid;
while(low<=high)
mid=(low+high)/2;
if(m<a[mid])
high=mid-1;
/********found**********/
else if(m>a[mid])
low=mid+1;
else return(mid);

return(-1);

void main( )
int i,a[N]=(-3,4,7,9,13,45,67,89,100,180),
k,m;
printf("a数组中的数据如下:");
for(i=0;i<N;i++)
printf("%d",a[i]);
printf("Enter m:");
scanf("%d",&m);
k=fun(a,m);
if(k>=0)
printf("m=%d,index=%d/n",m,k);
else printf("Not be found /n");

[填空题]下列给定程序中,函数fun( )的功能是:找出一个大于给定整数m且紧随m的素数,并作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#include <stdio.h>
int fun( int m)
int i,k;
for (i=m+1; ;i++)
for (k=2;k<i;k++)
/*************found**************/
if (i%k!=0)
break;
/*************found**************/
if (k<i)
return(i);


main( )
int n;
clrscr ( );
printf("/nPlease enter n: ");
scanf ("%d", &n);
printf ("%d/n",fun(n));

[填空题]下列给定程序中,函数fun( )的功能是:判断一个整数m是否是素数,若是返回l,否则返回0。在main( )函数中,若fun( )返回1则输出YES,若fun( )返回0则输出NO! 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #include <stdio.h> int fun(int m) { int k=2; while (k<=m&&(m%k)) /*************found*********************/ k++ /*************found*********************/ if(m=k) return 1; else return O; } main ( ) { iht n; clrscr ( ); printf("/nPlease enter n: "); scanf ("%d", &n); if (fun (n)) printf ("YES/n"); else printf ("NO! /n"); }
[填空题]给定程序的功能是:调用函数fun将指定源文件中的内容复制到指定的目标文件中,复制成功时函数返回值为1,失败时返回值为0。在复制的过程中,把复制的内容输出到终端屏幕。主函数中源文件名放在数组sfname中,目标文件名放在数组tfname中。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<stdlib.h>
int fun(char *source,char *target)
FILE *fs,*ft;
char ch;
/**********found**********/
if((fs=fopen(source, (1) ))==NULL)return 0;
if((ft=fopen(target,"w"))==NULL)return 0;
printf("/nThe data in file: /n");
eh=fgetc(fs);
/**********found**********/
while(!feof( (2) ))

putehar(ch);
/**********found**********/
fpute(ch, (3) );
ch=fgetc(fs);

fclose(fs);
fclose(ft);
printf("/n/n");
return 1;

void main( )
char sfname[20]="myfile1",tfname[20]="myfile2";
FILE *myf;
int i;
char c;
myf=fopen(sfname,"w");
printf("/nThe original data: /n");
for(i=1;i<30;i
[简答题]给定一个函数,其函数功能为:使10个整数按由小到大的顺序排列。在主函数中输入10个数,并输出结果。使用VC6打开考生文件夹下的工程RevProj5。此工程包含一个源程序文件RevMain5.cpp,该程序实现上述功能。但此程序运行有问题。请找出错误的地方,改正后将此程序调试正确。
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main( )

void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers/n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)

if((p-&data[0]) %5==0)
cout<<" /n";
cout<<setw (5) <<*p;

sort (data, 10);
cout<<"/n the present array is:";
for(p=data;p〈data+10;p++)

if((p-&data[0])%5==0) cout<<"/n";
cout<<setw (5)<<*p;


void sort(int array[],int n)

/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)

for (p2=p1+1 ;p2<array+n;p
[简答题]改错题 下列给定程序中,函数fun( )的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。 例如:输入dafhc,则应输出hfdca。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include /**********************found***********************/ int fun(char t[ ]) { char c; int i,j; for(i=0;i
[简答题]下列给定程序是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数fun( )的功能是:将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并作为函数值返回。
和值通过函数值返回main( )函数。例如,若n=5,则应输出8.391667。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<stdio.h>
#include<stdlib.h>
typedef struct aa

int data;
struct aa*next:
)NODE;
int fun(NODE *h)

int sum=0;
NODE*p;
/***********found**********/
p=h;
while(p->next)

if(p->data%2==0)
sum+=P->data;
/***********found***********/
p=h->next;

return sum;

NODE *creatlink(int n)

NODE*h,*p,*s,*q;
int i,x;
h=p=(NODE*)malloc(sizeof(NODE));
for(i=1;i<=n;i++)

S=(NODE*)malloc(sizeof(NODE));
s->data=rand( )%16;
s->next=p->next;
p->next=s;
p=p->next;

p->next=NULL;
return h;

outlink(NODE*h,FILE*pf)

NODE*p;
p=h->next;
fprintf(pf,"/n/nTHE LIST:/n/n HEAD");
while(p)
[填空题]下列给定程序中函数fun的功能是:求两个非零正整数的最大公约数,并作为函数值返回。
例如,若num1和num2分别为49和21,则输出的最大公约数为7;若num1和num2分别为27和81,则输出的最大公约数为27。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(int a,int b)

int r,t:
if(a<b)
/*********found*********/
t=a;b=a;a=t;
r=a%b;
while(r!=0)
a=b;b=r;r=a%b;
/*********found*********/
return(a);

void main( )

int num1,hum2,a;
printf("Input num1 num2:");
scanf("%d%d",&num1,&num2);
printf("num1=%d num2=%d/n/n",num1,num2);
a=fun(num1,num2):
printf("The maximun common divisor is%d/n/n",a);

[填空题]下列给定程序中函数fun的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为87653142时,t中的数为7531。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void fun(long s,long*t)

int d;
long s1=1;
/*********found*********/
t=0;
while(s>0)

d=s%10;
/*********found*********/
if(d%2==0)

*t=d*s1+*t:
s1*=10:

s/=10;


void main( )

long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%id",&s);
fun(s,&t);
printf("The result is:%id/n",t);

[填空题]下列给定程序中函数fun( )的功能是;从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放在t中。例如,当s中的数为4576235时,t中的数为4725。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<conio.h>
/************found*************/
int fun(long s,long *t)

long s1=l0;
*tis%10;
while(s>0)

/*************found*************/
s=s%100;
*t=s%10*s1+*t;
s1=s1*10;


main( )

long s,t;
clrscr( );
printf("/nPlease enter s:");
scanf("%ld",&s);
fun(s,&t);
printf("The result is:%ld/n",t);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码