题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-26 20:51:15

[简答题]下列给定程序中,函数fun的功能是:传入一个整数m,计算如下公式的值。
t=1/2-1/3-…-1/m
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动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 %1f/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
[简答题]改错题 下列给定程序中,函数fun( )的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。 例如:输入dafhc,则应输出hfdca。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include /**********************found***********************/ int fun(char t[ ]) { char c; int i,j; for(i=0;i
[简答题]给定程序中函数fun的功能是:将一个由八进制数字字符组成的字符串转换为与其值相等的十进制整数。规定输入的字符串最多只能包含5位八进制数字字符。
例如,若输入:77777,则输出将是:32767。
请改正程序中的错误,使它能得到正确结果。
[注意] 不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int fun(char *p)

int n;
/**********found**********/
n=*p-’o’;
p++;
while(*p!=0)
/**********found**********/
n=n*8+*p-’o’;
p++;

return n;

main( )

char s[6]; int i; int n;
printf("Enter a string(Ocatal digits):");
gets(s);
if(strlen(s)>5)

printf("Error: String too longer!/n/n");
exit(0);

for(i=0; s[i]; i++)
if(s[i]<’0’||s[i]>’7’)

printf("Error: %c not is ocatal digits!/n/n", s[i]);
exit(0);

printf("The original string:");
puts(s);
n=fun(s);
printf("/n%s iS convered to integer number: %d/n/n", s, n);

[填空题]给定程序中已建立一个带有头结点的单向链表,在main函数中将多次调用fun函数,每调用一次fun函数,输出链表尾部结点中的数据,并释放该结点,使链表缩短。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序]
#include<stdio.h>
#include<stdlib.h>
#define N 8
typedef struct list

int data;
struct list *next;
SLIST;
void fun(SLIST *p)

SLIST *t, *s;
t=P->next;
s=p;
while(t->next!=NULL)

s=t;
/*********found**********/
t=t-> (1) ;

/**********found**********/
printf(”%d”, (2) );
s->next=NULL:
/**********found**********/
free( (3) );

SLIST *creatlist(int *a)

SLIST *h, *p, *q;
int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)

q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i];
p->next=q;
p=q;

P->next=0;
return h;

void outlist(SLIST *h)

SLIST *p;
p=h->next;
if(
[简答题]

下列给定程序是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数fun( )的功能是:将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并作为函数值返回。
其累加和通过函数值返回main( )函数。例如,若n=5,则应输出8.391667。
请改正程序中的错误,使它能得到正确结果。
[注意] 不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<stdio.h>
#include<stdiib.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(si zeof(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)


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

long s1=10;
s/=10;
*t=s% 10;
/************found************/
while(s<0)

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


msin( )

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

[简答题]

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

long s1=10;
s/=10;
*t=s%10;
/************found************/
while(s<0)

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


mein( )

long s,t;
printf("/nPlease enter s:");
scanf("%1d",&s);
fun(s,&t);
printf("The result is:%1d/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);

[填空题]给定程序MODI1.C中函数fun的功能是:找出一个大于形参m且紧随m的素数,并作为函数值返回。
请改正程序中的错误,使程序能输出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#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);


void main( )
int m,n;
printf("Please enter an integer number:/n"):
scanf("%d",&m);
n=fun(m);
printf("The prime number after m:/n");
printf("%d/n",n);

[简答题]给定程序中,函数fun的功能是根据形参i的值返回某个函数的值。当调用正确时, 程序输出: x1=5.000000, x2=3.000000, x1*x1+x1*x2=40.000000 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include double f1(double x) { return x*x; } double f2(double x, double y) { return x*y; } __1__ fun(int i, double x, double y) { if (i==1) return __2__(x); else return __3__(x, y); } main( ) { double x1=5, x2=3, r; r = fun(1, x1, x2); r += fun(2, x1, x2); printf("/nx1=%f, x2=%f, x1*x1+x1*x2=%f/n/n",x1, x2, r); }

我来回答:

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

订单号:

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