ImageVerifierCode 换一换
格式:DOCX , 页数:33 ,大小:19.13KB ,
资源ID:5734969      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5734969.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(二级C语言上机题库.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

二级C语言上机题库.docx

1、二级C语言上机题库题库一一、填空题请补充fun函数,fun函数的功能是求m的阶乘。 请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。 注意:部分源程序给出如下。 1 # include 2 long fun(int m) 3 4 if(_1_) 5 return (m*fun(_2_); 6 return _3_; 7 8 main() 9 10 printf(8!=%ldn,fun(8); 11 二、改错题下列给定程序的功能是:读入一个整数n(2n5000),打印它的所有为素数的因子。例如,若输入整数1234,则应输出:2、617。请修改程序中

2、的错误,使程序能得出正确的结果。 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。1 # include 2 # include 3 /*error*/ 4 Prime(int m); 5 6 int j,p; 7 p=1; 8 /*error*/ 9 for(j=2;jm;j+) 10 if!(m%j) 11 12 p=0; 13 break; 14 15 return(p); 16 17 main() 18 19 int i,n; 20 printf(nplease enter an integer number between 2 and 5000:); 21 scan

3、f(%d,&n); 22 printf(nnThe prime factor(s) of %d is(are):,n); 23 for(i=2;in;i+) 24 if(!(n%i) & (Prime(i) 25 printf( %4d,i); 26 printf(n); 27 三、编程题数组point中存放着m个人的成绩,请编写函数fun,它的功能是:返回高于平均分的人数,并将高于平均分的分数放在high所指的数组中。例如,当point数组中的数据为50、60、65、70、75、80、88、90、95时,函数返回的人数应该是5,high中的数据应为75、80、88、90、95。请勿改动主函数

4、main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 注意:部分源程序给出如下。1 # include 2 # include 3 # include 4 int fun(int point,int n,int high) 5 6 7 8 main() 9 10 int j,m,high9; 11 int point9=50,60,65,70,75,80, 88,90,95; 12 FILE *out; 13 m=fun(point,9,high); 14 printf(nHigh the average point are :); 15 out=fopen(outf

5、ile.dat,w); 16 for(j=0;jm;j+) 17 18 printf(%d ,highj); 19 fprintf(out,%dn0,highj); 20 21 fclose(out); 22 题库二一、填空题请补充fun函数,该函数的功能是:判断一个年份是否为闰年。例如,2007年不是闰年,2008是闰年。 请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。 注意:部分源程序给出如下。1 # include 2 # include 3 int fun(int n) 4 5 int flag=0; 6 if(n%4=0) 7 if(

6、_1_) 8 flag=1; 9 if(_2_) 10 flag=1; 11 return _3_; 12 13 main() 14 15 int year; 16 printf(Input the year:); 17 scanf(%d,&year); 18 if(fun(year) 19 printf(%d is a leap year.n,year); 20 else 21 printf(%d is not a leap year.n,year); 22 二、改错题下列给定程序中,fun函数的功能是:根据形参n,计算如下公式的值。 例如,若输入5,则应输出2.28333。请修改程序中的错

7、误或在横线处填上适当的内容并把横线删除,使它能计算出正确的结果。注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。1 # include 2 # include 3 double fun(int n) 4 5 double s=1.0; 6 int i; 7 /*error*/ 8 for(i=2;i=n;i+) 9 s+=1.0/k; 10 /*error*/ 11 _填 空_ 12 13 main() 14 15 int n; 16 printf(nplease enter 1 integer numbers:n); 17 scanf(%d,&n); 18 printf(n

8、nthe result is %lfn,fun(n); 19 三、编程题请编写函数fun,它的功能是:求出1到500之内能被7或11整除,但不能同时被7和11整除的所有整数,并将它们放在b所指的数组中,通过m返回这些数的个数。 请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 注意:部分源程序给出如下。 1 # include 2 # include 3 void fun(int *b,int *m) 4 5 6 7 main() 8 9 int a500,m,i; 10 FILE *out; 11 fun(a,&m); 12 out=fopen(o

9、utfile.dat,w); 13 for(i=0;im;i+) 14 if(i+1)%10=0) 15 16 printf(%5dn,ai); 17 fprintf(out,dn,ai); 18 19 else 20 21 printf(%5d,ai); 22 fprintf(out,%d,ai); 23 24 fclose(out); 25 题库三函数fun的功能是:从三个形参x、y、z中找出中间的那个数,作为函数值返回。例如,当x=121,y=456,z=333时,中间的数为333。 请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。 注意:

10、部分源程序给出如下。1 # include 2 int fun(int a,int b,int c) 3 4 int temp; 5 temp=(ab) ? (bc ? b : (ac ? c : _1_) : 6 (ac) ? _2_ : 7 (bc) ? c : _3_); 8 return temp; 9 10 main() 11 12 int x=121,y=456,z=333,mid; 13 mid=fun(x,y,z); 14 printf(nThe middle number is : %dn,mid); 15 二、改错题下列给定程序中,函数fun和quest的功能是:用二分法求

11、方程2x3-4x2+3x-6=0的一个根,并要求绝对误差不超过0.001。例如,若给m输入-50,给n输入30,则函数求得的一个根值为2.000。请修改程序中的错误,得出正确的结果。注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。1 # include 2 # include 3 double quest(double x) 4 5 return (2*x*x*x-4*x*x+3*x-6); 6 7 double fun(double m,double n) 8 9 /*error*/ 10 int r; 11 r=(m+n)/2; 12 /*error*/ 13 while

12、(fabs(n-m)0.001) 14 15 if(quest(r)*quest(n)0) 16 m=r; 17 else 18 n=r; 19 r=(m+n)/2; 20 21 return r; 22 23 main() 24 25 double m,n,result; 26 printf(Please input m n : n); 27 scanf(%lf%lf,&m,&n); 28 result=fun(m,n); 29 printf(result=%6.3fn,result); 30 三、编程题请编写函数void fun(int y,int b,int*m),它的功能是:求出能整除

13、y且是奇数的各整数,并按从小到大的顺序放在b所指的数组中,这些除数的个数通过形参m返回。例如,若y中的值为90,则有4个数符合要求,它们是1、3、5、9、15、45。请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 注意:部分源程序给出如下。1 # include 2 # include 3 void fun(int y,int b,int *m) 4 5 6 7 main() 8 9 int y,a500,m,j; 10 FILE *out; 11 printf(nPlease input an integer number:n); 12 scan

14、f(%d,&y); 13 fun(y,a,&m); 14 for(j=0;jm;j+) 15 printf(%d ,aj); 16 printf(n); 17 fun(730,a,&m); 18 out=fopen(outfile.dat,w); 19 for(j=0;jm;j+) 20 fprintf(out,%dn,aj); 21 fclose(out); 22 题库四一、填空题请补充函数fun(char *t),该函数的功能是把字符串中的内容逆置。例如,字符串中原有的字符串为ABCDE,则调用该函数后,串中的内容为EDCBA。请勿改动主函数main与其他函数中的任何内容,仅在fun函数的

15、横线上填写所需的若干表达式或语句。 注意:部分源程序给出如下。1 # include 2 # include 3 # include 4 # define M 60 5 void fun(char *t) 6 7 int j,m=strlen(t)-1; 8 char s; 9 for(j=0;jm;j+,_1_) 10 11 s=tj; 12 _2_; 13 _3_; 14 15 16 main() 17 18 char bM; 19 printf(Input a string:); 20 gets(b); 21 printf(The original string is:); 22 put

16、s(b); 23 fun(b); 24 printf(n); 25 printf(The reversal string :); 26 puts(b); 27 二、改错题下列给定程序中,函数fun的功能是:判断字符ch是否与s所指串中的某个字符相同,若相同,则什么也不做;若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的操作。注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。1 # include 2 # include 3 # include 4 /*error*/ 5 void fun(char s,char c) 6 7 while(*s & *s!=c)

17、8 s+; 9 /*error*/ 10 if(*s=c) 11 12 s0=c; 13 /*error*/ 14 s1=0; 15 16 17 main() 18 19 char str81,ch; 20 printf(n Please enter a string:n); 21 gets(str); 22 printf(n Please enter the character to search:); 23 ch=getchar(); 24 fun(str,ch); 25 printf(nThe result is %sn,str); 26 三、编程题请编写函数fun,函数的功能是求出二维

18、数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。例如,若二维数组中的值为:357999949998则函数值为72。请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 注意:部分源程序给出如下。1 # include 2 # include 3 # define M 3 4 # define N 4 5 int fun(int bMN) 6 7 8 9 main() 10 11 int aMN=3,5,7,9,9,9,9,4, 9,9,9,8; 12 int i,j,sum; 13 FILE *out; 14 printf(The original data is : n); 15 for(i=0;iM;i+) 16 17 for(j=0;jN;j+) 18 printf(%6d,aij); 19 printf(n); 20 21 sum=fun(a); 22 printf(nThe sum: %dn,sum); 23 printf(n); 24 out=fopen(outfile.dat,w); 25 fprintf(out,%d,sum); 26 fclose(out); 28

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1