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

开通VIP
 

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

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

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(2021年福建省计算机二级考试C语言上机题库改错填空编程.doc)为本站上传会员【二***】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

2021年福建省计算机二级考试C语言上机题库改错填空编程.doc

1、二、改错题 Cmody191.c 修改程序,用以计算1~100之间所有偶数之和。 #include #include void main( ) { int i=1; /**/ int sum=2 /**/; while(i++,i<=100) { if(/**/ i==(i/2)*2 /**/) continue; sum+=i; } printf("Sum is %d\n",sum); getch(); } Cmody192.c 修改程序,将二维数组表达方阵左下半三角(

2、不含对角线)各元素加4,右上半三角(含对角线)各元素乘2。 #include #define N 5 void main() { int a[N][N],i,j; for(i=0;i

3、 for(i=0;i

4、mody201.c 修改程序,计算满足如下条件整数n最大值。 22+42+62+82+……+n2<1000 #include #include void main() { int n=0,sum=0; /**/ while(sum<1000);/**/ { /**/ sum+=n^2 /**/; n++,n++; } printf("n=%d\n",n-2); getch(); } Cmody202.c 修改程序,实现从键盘输入一串字符,并在字符串中从第m个字符串开始截取n个

5、字符。 例如:输入字符串为”welcome”,m=2,n=3,则截取字串为”elc” #include #include void main() { char str[100],sub[100]; int m,n,len,i; printf("Enter string:"); gets(str); printf("\nEnter m n:"); scanf("%d%d",&m,&n); len=strlen(str); if( m-1+n>len ) printf("Can't ru

6、n with %d and %d!\n",m,n); else { i=0; /**/ while(i<=n) /**/ { /**/ sub[i]=str[m+i];/**/ i++; } /**/ sub[i]='\n';/**/ printf("sub string is:%s\n",sub); } getch(); } Cmody211.c 修改程序,实现输入一整型二维数组,计算其中数组元素最大值与最小值差。 #include #include #

7、define ROW 3 #define COL 4 void main() { int a[ROW][COL],max,min,i,j,result; clrscr(); printf("Enter array a:\n"); for(i=0;i

8、/) min=a[i][j]; if(a[i][j]>max) /**/ max=a[i][j] /**/ } printf("Result= %d\n",max-min); getch(); }  Cmody212.c 修改程序cmody212.c,实现从键盘输入一串字符和一种字串,输出该子串在原字符串中浮现次数。 #include #include void main() { int i,j,k,count; char s1[

9、100],s2[100]; printf("Enter main String:"); gets(s1); printf("Enter Sub String:"); gets(s2); count=0; /**/ for(i=0;*s1!='\0';i++) /**/ { /**/ for(k=0;(s1[j]==s2[k])&&(s1[j]!='\0');j++,k++ );/**/ if(s2[k]=='\0') count++; } printf("\nCount=%d\n",count); getch();

10、 } Cmody221.c 修改程序,输出存储在构造体数组中8位学生成绩平均分以及最高学生姓名 #include /**/ structure student /**/ { char name[10]; float score; }; void main( ) { struct student stu[8]={{"Mary",76},{"John",85}, {"Tom",81},{"Susa",87},{"Wilu",79},{"Yili",65},{"Sonmu",73},{"Lichar",70}}; int i=0,

11、mrk; float total=0,aver,max; max=stu[0].score; mrk=0; while(i<8) { /**/ total=total+stu[i]; /**/ if(stu[i].score>max) {max=stu[i].score; mrk=i; } /**/ i++ /**/ } aver=total/8; printf("\naver=%.2f \n Best is %s\n",aver,stu[mrk].n

12、ame); getch(); } Cmody222.c 修改程序,完毕其中n个字符串升序排列 #include #include #define ROW 5 #define COL 30 void fun(char s[][COL],int n) { char temp[COL]; int i,j; for(i=0;i0) { s

13、trcpy(temp,s[i]); strcpy(s[i],s[j]); strcpy(s[j],temp); } } void main() { int i; char str[][COL]={"DEF","BAEELCS","FHIAME","CBADF","APMAE"}; /**/ fun(str,COL);/**/ clrscr(); for(i=0;i

14、c,实现将输入十进制正整数转换成十六进制数,且用字符串存储该十六进制数 #include #include #include void main() { int x,b,i,j; char s[5]; printf("Input a number(Dec):"); scanf("%d",&x); /**/ i=1;/**/ while(x>0) {b=x%16; if(b>9) s[i]=b-10+'A'; else /**

15、/ s[i]=b /**/; x=x/16; i++; } printf("\nHex number is:"); for(j=i-1;j>=0;j--) putchar(/**/ s[i] /**/); getch(); } Cmody232.c 修改程序cmody232.c,输出下列9行数字金字塔 1 121 12321 1234321 ……………………… 54321 #include void main() {

16、 int i,j,k; for(k=1;k<=9;k++) { /**/ for(i=0;i<=k;i++) /**/ printf(" "); for(i=1;i<=k;i++) printf("%d",i); /**/ for(j=k-1;j>1;j--) /**/ printf("%d",j); printf("\n"); } getch( ); } 三、填空题 Ccon191.c 程序ccon

17、191.c,从键盘输入3个实型值,若它们能构成一种三角形(即任意两边之和不不大于第三边),则依照如下公式求该三角形面积;否则,提示相应信息。 #include #include void main() { float a,b,c,d,area; printf("Please input 3 numbers:\n"); scanf("%f,%f,%f",&a,&b,&c); if( a+b>c /**/ /**/) {d = (a+b+c)/2; area = /**/

18、 /**/; printf("area is %.2f\n",area); } else printf("Not Triangle!\n"); getch(); } Ccon192.c 程序ccon192.c,计算:已知大货车限载8吨、中型货车限载3吨、微型货车限载1吨,需50辆车运送100吨货品时,应配备大、中、微型车分别多少辆?共有多少种解决方案? #include #include int /**/ /**/( ) {

19、 int big,median,small,n=0; printf(" big median small \n"); for(big=0;big<=13;/**/ /**/) for(median=0;median<=33;median++) { small=100-8*big-3*median; if(/**/ /**/==50) { n++; printf("%d-->%2d %2d %2d\n

20、", n,big,median,small); } } return n; } void main() { int num; num = fun(); printf("\n There are %d solutions.\n",num); getch(); } Ccon201.c 程序ccon201.c,按照如下袋装状况求一堆苹果总数,总数在100~300之间。若按每袋装8个苹果则多余5个,若按每袋装7个苹果,则多余4个,若按每袋装5个苹果,则多余2个。 #include void main()

21、{ int n; for( n=300;/**/ /**/;n-- ) {if( n%8 == 5) if( !((n-4)%7) /**/ /**/) printf("n=%d\n",n); } getch(); } Ccon202.c 程序ccon202.c中swap函数,通过指针变量实现两个变量值互换。 #include void swap(/**/ /**/) { int sum; sum = *p1+*p2

22、 *p1 =/**/ /**/; *p2 = sum-*p1; } void main() { int x,y; printf("please input 2 numbers:\n"); scanf("%d,%d",&x,&y); printf("\nOriginal:x=%d y=%d\n",x,y); swap(&x,&y); printf("\nNow:x=%d y=%d\n",x,y); getch(); } Ccon211.c 程序ccon211.c,按每行最多5个数方式输出100~400之

23、间能同步被7和4整除所有数及它们之和。 #include void main() { int i,n; int sum=0; /**/ /**/ for(i=101;i<=399;i++) { if(/**/ /**/ && !(i%4) ) {printf("%d ",i); sum+=/**/ /**/; n++; if(n%5==0) printf("\n"); } } p

24、rintf("\n sum=%d\n",sum); getch(); } Ccon212.c 程序ccon212.c中cmob函数用以输出等式a*b*c+a*c*c=560所有a,b,c组合(其中a,b,c只取1~9之间一位整数)。如a=7,b=2,c=8时,7*2*8+7*8*8=560 #include void comb(/**/ /**/) {int a,b,c; for( a=1;a<10;a++ ) for( b=1;b<10;b++ ) for( c=1;c<10;c++ )

25、{ if(/**/ /**/ ==m) printf("a=%d,b=%d,c=%d\n",a,b,c); } } void main() { int result=560; comb(result); getch(); } Ccon221.c 程序ccon221.c,输出如下图形 % % % % % % % & & & & & & % % % % % & & & & % % % & & % #include #include

26、 void main() { int row,col; for (row=1;row<=7;row++) { printf("\t"); for(col=1;col<=/**/ /**/ ;col++) if(row%2) printf("%c",/**/ /**/); else printf("%c",/**/ /**/); printf("\n"); } getch(); }

27、Ccon222.c 程序ccon222.c中pnt函数,依照参数n(2≤n≤10),输出类似如下所示方针(n=5). 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 24 25 #include #include #define M 10 void pnt(int a[M][M],int n) {int i,/**/ /**/; for(i=0;i

28、0) a[i][j]=/**/ /**/; else a[i][j]=i*n+n-j; } printf("array a(n=%d) is:\n",n); for(i=0;i

29、 scanf("%d",&n); pnt(/**/ /**/,n); getch(); } Ccon231.c 程序ccon231.c,计算如下分数序列前18项之和 #include void main() { int i; float sum,a=2,b=1,t; /**/ /**/; for (i=1;i<=18;i++) { sum+=/**/ /**/; t=a; a=a+b; b=/**/ /**/; }

30、 printf("sum=%f\n",sum); getch(); } Ccon232.c 程序ccon232.c中inv函数,通过指针变量将字符串str内容”asdfjk”,调用inv函数后,变成:”kjfdsa”。 #include #include void inv(char *str) {int i,j,k; j=/**/ /**/; for(i=0;i

31、 *(str+j)=/**/ /**/; } } void main( ) { char str[]="asdfjk"; printf("\n Original is:%s\n",str); inv(str); printf("\n Now is:%s\n",str); getch(); } 四、编程题 cprog191.c 打开程序cprog191.c,完毕其中fun函数:依照输入汇款数额,求应交汇费。设应交汇费计算公式如下: #include #include

32、 double fun(float x) { /**/ /**/ } void main() { float x; double y; clrscr(); printf("Please input a number:\n"); scanf("%f",&x); y = fun(x); printf("f(%.2f)=%.2f\n",x,y); getch(); } cprog192.c 打开程序cprog192.c,完毕其中fun函数:对4×4矩阵从顶行开始各行按从左到右顺序查找,找出各行中0元素之后所

33、有负数,并按元素浮现先后顺序存储到数组b中,并返回这些负数之和。如矩阵为: 则调用函数fun( )后,数组b各元素依次为-3,-1,-4,-3,-12,-13,并返回-36. #include #include #define ROW 4 #define COL 4 #define LEN 12 int fun(int a[][COL],int b[]) { /**/ /**/ } void main( ) { int arra[ROW][COL]={{-2,0,-3,-1},{-8,2,

34、0,-4}, {0,3,-3,-12},{21,0,-13,3}}; int arrb[LEN],i,result; for(i=0;i

35、 ); } cprog201.c 打开cprog201.c,完毕其中函数fun,该函数数学表达式是 #include #include double fun(float x) { /**/ /**/ } void main( ) { float x; double y; printf("Please input a number:\n"); scanf("%f",&x); y = fun(x); printf("f(%.3f)=%.3f\n",x,y); ge

36、tch(); } cprog202.c 打开程序cprog202.c,完毕其中fun函数: 函数fun(double x,int n),用如下公式近似计算cos(x)值: #include void main() { double x; int n; double fun(double x,int n); printf("Please enter x,n:"); scanf("%lf%d",&x,&n); printf("cos(%lf)=%lf\n",x,fun(x,n)); getch();

37、 } double fun(double x,int n) { /**/ /**/ } cprog211.c 打开cprog211.c,完毕其中函数fun,该函数数学表达式是 #include #include double fun(float x) { /**/ /**/ } void main( ) { float x; double y; clrscr(); printf("Please input a number:\n")

38、 scanf("%f",&x); y = fun(x); printf("f(%.2f)=%.2f\n",x,y); getch( ); } cprog212.c 打开程序cprog212.c,完毕其中fun函数:对两个字符串中小写英文字母个数进行比较,并返回比较成果。(注:第1个字符串比第2个字符串小写英文字母个数多,则返回正数,相等返回0,个数少则返回负数) 例如:字符串str1为“abc123”,字符串str2为”abcd”,则函数fun返回值应不大于0。 #include int fun(char *str1,char *str

39、2) { /**/ /**/ } void main( ) { int rela; char *str1,*str2; clrscr(); printf("Please input string NO.1:"); gets(str1); printf("Please input string NO.2:"); gets(str2); rela=fun(str1,str2); if(rela>0) printf("Numbers of Lower char in %s > Numbe

40、rs of Lower char in %s",str1,str2); if(rela==0) printf("Numbers of Lower char in %s = Numbers of Lower char in %s",str1,str2); if(rela<0) printf("Numbers of Lower char in %s < Numbers of Lower char in %s",str1,str2); getch(); } cprog221.c 打开程序cporg221.c,完毕其中fun函数:依照输入x和y值,按

41、如下公式计算: 将计算成果整数某些存入数组元素arr[0],并将该计算成果小数某些前两位存入arr[1]中。 #include #include void fun(int arr[],double x,int y) { /**/ /**/ } void main() { int y; double x; int arra[2]; printf("Please enter x(1

42、 if((x>1.0 &&x<2.0)&&(y>0 && y<=6)) { fun(arra,x,y); printf("\npart1=%d,part2=%d",arra[0],arra[1]); } else printf("x or y is out of range!"); getch(); } cprog222.c 打开程序cprog222.c,完毕其中fun函数:将一种升序数组a和一种降序数组b中所有元素按降序存入数组c中。 例如:数组a为{5,10,15,27,46},数组b为{50,45,42,2

43、9,15,8,5,2},则数组c就应为{50,46,45,42,29,27,15,15,10,8,5,5,2}。 #include #define N 5 #define M 8 void fun(int a[],int b[],int c[]) { /**/ /**/ } void main() { int arra[N]={5,10,15,27,46},arrb[M]={50,45,42,29,15,8,5,2}; int arrc[N+M],k; fun(arra,arrb,arrc);

44、 printf("array arra is:"); for(k=0;k

45、og231.c,完毕其中函数fun,该函数递归公式是: #include #include void main() { double x; int n; double fun(double x,int n); printf("Please enter x,n:\n"); scanf("%lf%d",&x,&n); printf("fun=%lf\n",fun(x,n)); getch(); } double fun(double x,int n) { /**/

46、 /**/ } cprog232.c 打开程序cprog232.c,完毕其中fun函数:返回一维数组中次大数(即仅不大于最大数数),设数组a中没有重复元素。 例如:数组元素为{45,58,33,24,40,20,30,28,31},函数fun返回值为45. #include #define ROW 9 int fun(int a[ ]) { /**/ /**/ } void main() { int arra[ROW]={45,58,33,24,40,20,30,28,31}; int ma

47、x_pre,i; max_pre=fun(arra); printf("array arra is:"); for(i=0;i

48、/;→if(i!=(i/2)*2) cmody192.c /**/ for(j=0;j<=i;j++)/**/→for(j=0;j

49、str[m-1+i]; /**/ sub[i]='\n';/**/→sub[i]= '\0' cmody211.c /**/ max=min=0;/**/→max=min=a[0][0]; /**/ mina[i][j] /**/ max=a[i][j] /**/→max=a[i][j]; cmody212.c /**/ for(i=0;*s1!='\0';i++) /**/ →for(i=0;*(s1+i)!=’\0’;i++) /**/ for(k=0;(s1[j]==s2[k])&&(s1[j]!='\0');j++,

50、k++ );/**/→ for(k=0,j=i;(s1[j]==s2[k]&&(s2[k]!=’\0’);j++,k++); cmody221.c /**/ structure student /**/→struct student /**/ total=total+stu[i]; /**/→ total=total+stu[i].score /**/ i++ /**/→i++; cmody222.c /**/ for (j=i+1;j

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服