C语言考试题库.pdf

上传人:无*** 文档编号:90870812 上传时间:2023-05-18 格式:PDF 页数:100 大小:7.37MB
返回 下载 相关 举报
C语言考试题库.pdf_第1页
第1页 / 共100页
C语言考试题库.pdf_第2页
第2页 / 共100页
点击查看更多>>
资源描述

《C语言考试题库.pdf》由会员分享,可在线阅读,更多相关《C语言考试题库.pdf(100页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、,0.69 分)1.利用指针法将两个数按从小到大的顺序输出来。尸程序设计基础DebugVt.exeInput:3 7Output:a=3 b=7max=7 min=3冈#includevoid main()(int a,b;int*p1,*p2;printf(lnput:nM);scanf(M%d%dM,&a,&b);p1=&a;p2=&b;printf(nOutput:nw);printf(*,a=%d b=%dnH,a,b);if(ab)(pnntf(Hmax=%d min=%d,*p1,*p2);)elseprintf(,max=%d min=%dM,*p2,*p1);)提交编程题(0.

2、69 分)2.使用结构体存储3 个同学的姓名、学号,并输出到屏幕。输入:一行输入一个同学的姓名和学号,中间间隔若干个空格输出参考 printf(%d:Name:%s No:%sn,Please input 3 student information:name numberzhangsan 1011lisi 1022v/angwu 1034Output:1:Name:zhangsan No:10112:Name:lisi No:10223:Name:wangwu No:1034Press any key to continueX提交编程题(0.69 分)3.请输出下列字符串:式-1二 程序设计基

3、础Debugt.exeOutput:This is a C program.X#iincludevoid main()(printf(nnOutput:nM);printf(This is a C program);)提交编程题(0.69 分)4.输入两个数,输出两个数的和,比如:铳 I:程序设计基础D e b u g t.exeInput :1 2 3 4 5 6Out put:Sum i s 5 7 9x#includevoid main()(int a,b,sum=0;printf(lnput:n);scanf(H%d%d,&a,&b);sum=a+b;printf(nOutput:nn

4、);printf(Sum is%dnM,sum);)提交编程题(0.69 分)5.输入一正整数,实现 从 1 开始乘到自身为止,即计算阶乘。输出结果按例子给定形式比如:工:程序设计基础D e b u g t-exe.i nput:3Out put:3!二 6includevoid main()int a,i=1,sum=1;printf(lnput:nM);scanf(n%d,&a);for(i=1;i=a;i+)sum=sum*i;printfCOutputAn);printf(%d!=%dnM,a,sum);)提交编程题(0.69 分)6.输入个除数,输入个被除数,输出商和余数,比如:软*

5、工:程序设计基础Debugt exeInput:5 2Out put:s h a ng:2|yu:1X#includevoid main()(int a,b,c,d;printf(lnput:nM);scanf(n%d%d,&a,&b);c=a/b;d=a%b;printf(Output:n);printffshang:%dn,c);printf(yu:%dnn,d);)提交编程题(0.69 分)7.输入两个整数,然后把这两个整数按照从大到小顺序输出。如图所示。式,1:程序设计基础口1)118t.3:8Input:1 2Output:2 1x#includevoid main()(int a,

6、b,c;printf(lnput:nH);scanf(w%d%d,&a,&b);printf(HnOutput:n);if(ba)(c=a;a=b;b=c;printf(%d%dnn,a,b);elseprintf(%d%dn,a,b);)提交编程题(0.69 分)8.编写程序,读入三个双精度数,求它们的平均值并保留此平均值小数点后 位数,最后输出结果。比如:京 I:程序设计基础D eb u g t exeInput:1 2.0 1 2.1 1 2.4 3Out put:a ve r a g e=1 2.2X#iincludevoid main()(double a,b,c;float d;p

7、rintf(lnput:n);scanf(H%lf%lf%ir,&a,&b,&c);d=(a+b+c)/3;printf(nOutput:n);printf(average=%5.1fn,d);)提交编程题(0.69 分)9.用宏定义的方式求a*b和(a+c)*b的值例如输入a,b,c依次为1,2,3a*b=2(a+c)*b=8 工:程序设计基础DebugVt.exeInput:1 2 3output:a*b=2(a+c)*b=8L_J#include#define N(a,b)a*b#define S(a,b,c)a*b+b*cvoid main()(int a,b,c;printfCInp

8、utAn1);scanf(%d%d%d;&a,&b,&c);pnntf(nOutput:nM);printfCa*b=%dn,1,N(a,b);printf(,(a+c)*b=%dn,S(a,b,c);)提交编程题(0.69 分)10.用宏定义的方式,求5=庆+庆T二 人*8例如:输 入1 2输出 Output:S=2T=2oleas e inp u t a b:1 2O u t p u t :S =2r=2 r es s any key t o cont inu eX#include#define S(a)a+adefine T(a,b)a*bvoid main()(int a,b;prin

9、tf(,please input a b:);scanf(H%d%d,&a,&b);printf(nOutput:nn);printf(,S=%dntS(a);printf(T=%dnH,T(a,b);)提交编程题(0.69 分)11.编写程序,读入三个整数给a、b、c,然后交换他们中的数,把a中原来的值给b,把b中原来的值给c,把c中原来的值给a,然后输出a,b,c。比如:a I:程序设计基础D ebugt.exellnput:14 12 24Output:Before swapping:a=14,6=12,c=24kfter exchang:a=245 b=14,c=12冈#include

10、void main()printf(lnput:nH);int a,b,c,t=O;scanf(,%d%d%d”,&a,&b,&c);printf(nOutput:nH);printff1 Before swapping:a=%d,b=%d,c=%dnM,a,b,c);t=c;c=b;b=a;a=t;printf(*After exchang:a=%d,b=%d,c=%dn,a,b,c);)提交编程题(0.69 分)12.编写程序,输入一位学生的生日(年:y0、月mo、日do),并输入当前的日期(年:yl、月m l、H d l),输出该生的实际年龄。比如:Enter a student,s b

11、irthday:1965 12 12Enter the current date:2000 12 12Output:age=35Press any key to continues#includevoid main()(int a,b,c;int x,y,z;printf(Enter a students birthday:nH);scanf(M%d%d%dM,&a,&b,&c);printffEnter the current date:n);scanf(H%d%d%d,&x,&y&z);intd;printf(HnOutput:);if(y=b&z=c)d=x-a;if(yb)d=x-a-

12、1;printf(age=%dn,d);)提交编程题(0.69 分)13.编写程序,输入一个整数,打印出它是奇数还是偶数。比如Please enter an integer:12Output:12 Is an un number?Pleas enter an integer:15Output:15 Is an odd number?#includevoid main()(int a;printf(Please enter an integer:nM);scanf(,%d,&a);printf(nOutput:n);if(a%2=0)printf(%d Is an even number!n,a

13、);elseprintf(%d Is an odd numberin1,a);)提交编程题(0.69 分)14.输入3 个数,对这三个数按照从小到大排序。如图:Please input 3 nums:3 1 2Output:1 2 3Press any key to continueX#includevoid main()(int a,b,c,temp;printf(Please input 3 nums:n);scanf(,%d%d%d,&a,&b,&c);if(ab)(temp=b;b=a;a=temp;)if(ac)(temp=c;c=a;a=temp;)if(bc)(temp=b;b=

14、c;c=temp;)printf(nOutput:n);printf(%d%d%dn,a,b,c);)提交编程题(0.69 分)15.输入一个正整数,求 从1到该数连续相加的和,如同下列公式的结果,比 如:输 入100,计 算1+2+3+4+100用例:input n:20Output:210区#includevoid main()int a,i,sum=O;printf(input n:n);scanf(%d,&a);for(i=1;i=a;i+)(sum=sum+i;)printf(nOutput:nn);printf(%dnJsum);)提交编程题(0.69 分)16.输入一年份判断是否

15、是闰年Input:2008Output:2008 is a leap year?Press any key to continueInput:2605Output:2005 is not a leap year?Press any key to continue,X#includevoid main()(int a;printfCInputAn*);scanf(%d,&a);printf(nOutput:nH);if(a%4=0&a%100!=0|a%400=0)printf(%d is a leap year!na);elseprintf(%d is not a leap year!,a);

16、)提交编程题(0.69 分)17.求方程ax2+bx+c=0的解要输入的数分别为a,b,c三个实数,其中有二种可能,两个一样的解,或者一正一负两个解,或者没解。输 出 格 式 为 两 个 数 之 间 加 参 考 程 序printf(%ft%ftn.)或者printf(No Answern);算法为设 A=b24acA0 时,x=(-b4A)/(2a)=0时,有两个样的根,x=(-b)/(2a)0时,由负数没有平方根,所以方程没有实数根。图示如卜.所示:提交编程题(0.69 分)18.输入一个偶数或奇数的行数分别输出如下图形Input:6O utput:M XMMInput:7Output:MM

17、MMMKMMMNMMMMMMMMMNMMMMM#includeint main()(int n,i,j;pnntf(lnput:H);scanf(%d,&n);pnntf(Output:n);for(i=0;in/2;i+)(for(j=0;jn/2-i;j+)(printfC);)forG=0;j2*i+1;j+)(printf(*);printf(n);)if(n%2!=0)(for(i=0;i=0;i-)(for(j=0;jn/2-i;j+)printf(M);)for(j=0;j 2*i+1;j+)(printf(*H);)printf(nM);)return 0;)提交编程题(0.6

18、9 分)19.从键盘读入行字符(约定:字符数W127字节),将其中的数字字符以及这些数字字符的数量在屏幕上显示,注意:要求先显示这些数字字符的数量。编程可用索材:printf(Please input string:).printf(nshu zi geshu wei:、printf(nshu zi wei:。程序的运行效果应类似地下图所示。Please input s trin g:sdfds78bu0,sdfkds9092879O70Output:shu zi ge shu wei:13shu zi kiei:7809092879070 x#include#includevoid main

19、()(chara127;char b127;int i,n=O,j=O;printf(Please input string:);gets(a);printf(n);for(i=0;i=0,&ai=9)n+;bj=ai;j+;)printf(nOutput:nH);printf(shu zi ge shu wei:%dnn,n);printf(shu zi wei:);for(i=0;ij;i+)(printf(%c,bi);printf(n);)提交编程题(0.69 分)20.用 scanf输入某年某月某日,判断这一天是这一年的第几天?以 3 月 5 口为例,应该先把前两个月的加起来,然后再

20、加上5 天即本年的第几天,特殊情况,闰年且输入月份N3时需考虑多加一天。注:判断年份是否为闰年的方法为 400的倍数为闰年,如 2000年;若 非 100的倍数,而是4 的倍数,为闰年,如 1996年。编程可用素材:printf(Please input:year-month-dayn).,printf(nlt is the.th day.n.程序的运行效果应类似地如图1 所示,图 1 中的1992-11-2是从键盘输入的内容。Please input:year-month-day1992-11-2Output:It is the 307th day.Press any key to cont

21、inueX#includevoid search(int a,int b.int c)(int yearQ=31,28,31,30,31,30,31,31,30,31,30,31);int i=0,sum=0;if(a%400=0|a%4=0&a%100!=0)(year1=29;)for(;ib-1;i+)(sum+=yeari;)sum+=c;printf(nOutput:nH);printf(lt is the%dth day.n,sum);)int main()(int a,b,c;printf(HPlease input:year-month-dayn);scanf(M%d-%d-%

22、dH,&a,&b,&c);search(a,b,c);return 0;)提交编程题(0.69 分)21.通过键盘输入摄氏温度X,然后根据X的值在屏幕上输出对应的信息。编程可用素材:printf(lnput:n);printf(nOutput:n);printf(verygood!);printf(hot!);printf(cold!);当温度低于18度时,在屏幕上输出对应的信息是“cold!”;当温度高于28度时,在屏幕上输出对应的信息是“hot!”;当温度在18度到28度之间时,在屏幕上输出对应的信息是“very good!”;。程序的运行效果应类似地如图1、图2、图3 所示,图1、图2、

23、图3 中的20.5、-30.9、40.8是从键盘输入的内容。苏 I:程序设计基础D ebugt.exeInput:20.5Output:very good!软*工:程序设计基础D ebugt.exeInput:-30.9Output:cold!友“工:程序设计基础D ebugVt.exellnput:40.8Output:hot!冈#includevoid main()(float i;printf(lnput:n);scanf(M%f,&i);printf(nOutput:nH);if(i28)(printfChotlNn*);)if(i=18&i=2),编写程序求 f(n)的 值(n 由键

24、盘输入,13=n=2).编程可用素材:printf(lnput the integer n(13=n=2):)程序的运行效果应类似地如图1 所示Input the integer n(13=n=2):10Output:f(10)=1819456Press any key to continue.X#includevoid main()(int n;printf(lnput the integer n(13=n=2):);scanf(%d,&n);if(n=0&n=2&n=13)printf(f(%d)=%d,n,)提交编程题(0.69 分)23.从键盘输入1 9 之间的一个数,根据输入的数,打

25、印下三角乘法口决表。要求积的输出占.3 个宽度,且左对齐。编程可用素材:printf(input:n);printf(nOutput:n);.o程序的运行效果应类似地如图1 和图2 所示,图 1 中的3 和图2 中的7 是从键盘输入的内容。Xc:r:Debugnl.exe*1I n p u t:7O u tp u t:1*1=12*1=22*2=43*1=3 3*2=6 3*3=94*1=4 4*2=8 4*3=1 2 4*4=1 65*1=5 5*2=1 0 5*3=1 5 5*4=2 0 5*5=2 56*1=6 6*2=1 2 6*3=1 8 6*4=2 4 6*5=3 0 6*6=3

26、67*1=7 7*2=1 4 7*3=2 1 7*4=2 8 7*5=3 5 7*6=4 2 7*7=4 9提交编程题(0.69 分)24.输入月份,打印2003年该月有几天。当输入的月份超范围时,应显示“Invalid month input。编程可用素材:printf(Mplease input the month number:).、printf(Mlnvalid month input!n).printf(2003.has.daysnH.o程序的运行效果应类似地如图1和图2所示,图1中的4和图2中的13是从键盘输入的内容。言“口:语言22761)1185173111-6*6.pleas

27、e input the month number:4Output:2003.4 has 30 daysPress any key to continue.软*D:c语言227D ebugsiyanl.exe*(please input the month number:13llnualid monthPress any keyinput to continue.提交编程题(0.69 分)25.已知某公司员工的保底薪水为500,某月所接工程的利润profit(整数)与利润提成的关系如卜(计量单位:元):profitWOO1000profit20002000profit50005000 profi

28、t1000010000 118!=6Input:120Output:F(120.00)=C(48.89)提交编程题(0.69 分)27.输入一个小写英文字母,首先输出它及其ASCII码,然后输出其对应的大写字母及其ASCII码。编程可用素材:printfflnput a lowercase letter:).、printf(n.(.).o程序的运行效果应类似地如图1 所示,图 1 中的y 是从键盘输入的内容。K D:c语言230D ebugvuyan6.exeInput a loviercase letterOutput:LVPress any key to continue提交编程题(0.6

29、9 分)28.从键盘输入日期,年月日之间以分隔,并以同样的形式但以7 作分隔符输出。程序的运行效果应类似地如图所示,图中的2009-12-9是从键盘输入的内容。please input a d a te:2009-12-9Output:the date is:2009/12/9Press any key to continueX提交编程题(0.69 分)29.用 scanf输入10个整数(采用int数据类型),计算所有正数的和、负数的和以及10个数的和。编程可用素材:printf(lnput 10 integers.nw).printf(,nzhengshu=.,fushu=.,all=.n.

30、o程序的运行效果应类似地如图1 所示,图 1 中的4 6 20-45 35 56-23-4 9 70是从键盘输入的内容。X提交编程题(0.69 分)30.输入两个整数,输出这两个整数的和,程序的运行效果应类似地如图1 所示,图 1 中的3 4是从键盘输入的内容。图 1:input n:3 4Output:3+4=7提交编程题(0.69 分)31.已知某产品单价是30,输入其数量是num,输出其总价.程序的运行效果应类似地如图1 所示,图 1 中的8 是从键盘输入的内容。I:程序设计基础D ebugt.exeInput:8Output:total=240提交编程题(0.69 分)32.输出n行星

31、号,每行5个*星号。编程可用素材:printf(please input n:程序的运行效果应类似地如图1所示,图1中的4是从键盘输入的内容。please input n:4Output:M M M M MM M*M *Press any key to continue提交编程题(0.69 分)33.从键盘读入个任意字符,输出该字符ASCII的十六进制值。编程可用素材:printfflnput a character:),printf(nOutput:n)程序的运行效果应类似地如图1所示,图1中的b是从键盘输入的内容。Output:Input a character:b62区提交文件题下载文件

32、34.有一存储很多商品数据(每件商品的属性先后包括:品名、规格、单价(有小数位)、数量,数据的最长长度分别为20、10、6,5.在文件中以空格为分隔,每个商品的数据占一行)的文本文件,从键盘输入某种商品的品名,要求在文件中查找有无相应品名商品(可能有多条记录或没有),若有则在屏幕上显示出相应的商品的品名、规格、数量、单价(显示时,品名、规格、数量、单价之间使用逗号(,)作分隔,单价显示时只显示2位小数),若无则显示没有相应品名的商品。运行时测试用的商品数据文件sp.txto编程可用素材:printf(Please input shang pin pin ming:).、printf(ncha

33、zhao qing kuang:n).printf(mei you shang pin程序的运行效果应类似地如图1和图2所示,图1中的Please input shang pin pin ming:xuebi中的xuebi和图2中的Please input shang pin pin ming:kele中的kele是从键盘输入的内容。冈提交文件题下载文件35.文件路径为D:/ASC12.fon文件格式说明:字符的点阵数据存储到文件ASC12.fon时,按字符的ASCII码(0 255)为序由前到后存储;字符为12(高产8(宽)点阵,存储时每行8 点为1字节(相应位为1 表示有点、为 0 表示无

34、点),从第1 行到第12行按序存放。程序运行时先显示Please input a char:,等待考生从键盘输入任一字符(例如I,如图1 中所示输入A)并按回车后,从前面给出的点阵字库文件中取出该字符的点阵数据。将该字符的点阵数据在屏幕上加框显示:相应位置有点则显示无点则显示“(空格),并且字符外围加框。程序的运行效果应严格地如图1所示。提交编程题(0.69 分)36.m个人的成绩存放在s c o r e数组中,请编写函数f u n,它的功能是:将低于平均分的人数作为函数值返回,并将低于平均分的分数放在b el o w 数组中。编程素材:p r i n t f(n 0 u t p u t:n

35、);p r i n t f(l es s t h a n a v er a g e s c o r e:n );please Input m:5please Input score:1 2 3 4 5Output:less than average score:1 2Press any key to continueX提交编程题(0.69 分)37.请 编 写 函 数f u n,其功能是:计算并输出s=1+(1+2(0.5)+(1+2(0.5)+3(0.5)+.+(1+2(0.5)+3(0.5)+.+n(0.5)用例:Input:5Output:20.000000,提交编程题(0.69 分)3

36、8.请 编 写 函 数f u n,它的功能是:求 出 1 至 3 0 0 之内能被7 或者11整除,但不能同时被7 和 11整除的所有整数,并将他们放在a 所指的数组中,通过n 返回这些数的个数。提交编程题#includeint fun(int x);void main()(int i,j,k=0,m;inta100;printf(lnput:nH);scanf(”d”,&j);for(i=1;i=j;i+)if(i%7=0&i%11!=0|i%7!=0&i%11=0)ak=i;m=fun(k);k+;)printf(nOutput:nn);for(i=0;in,p=m!/(n!(m-n)!)

37、O u t p u t :1 0,0 0 0 0 0 0X提交编程题(0.69 分)44.请编写函数void fun(int x,int ppjint*n),它的功能是:求出能整除x 且不是偶数的各整数,并按从大到小的顺序放在pp所指的数组中,这些除数的个数通过形参n 返回。please input n:9Output:th result is:9 3 1Press any key to continue提交编程题(0.69 分)45.编写一程序实现以下功能设某企业2006年的产值为5000万,计划以后每年的增长率为x(x从键盘输入,例如输入8.75表 示8.75%),计算该企业的产值在哪年实

38、现翻番以及翻番时的产值,然后输出(输出时以万为单位,应考虑有小数)0编程可用素材:printf(Please input x:printf(nyear=.nian,chanzhi=.n.o程序的运行效果:Please input growth rate:50.6Output:year:2008total value:11340.180G64Press any key to continue,X提交编程题(0.69 分)46.巳知某银行整存整取存款不同期限的年息利率分别为:3.15%期限一年,3.63%期限二年,4.02%期限三年,4.69%期限五年,5.36%期限八年。从键盘上输入存钱的本金(

39、以元为单位,必须定义为int且应考虑金额很大的情况)和存款期限(只考虑1,2,3,5,8),求到期时能从银行得到的利息(以元为单位,应考虑有小数,不计复利)。编程可用素材:printf(nPlease inputbenjin,cunqi:).printf(nlixi=.yuan.程序的运行效果应类似地如图1 所示,图 1 中的10000,8是从键盘输入的内容。寂 c:docuMents and sett ingsVadainist rat oray docwient svisual studio 20.iflease input benjing,cunqi12.2sac3Output:lixi

40、=0.87 yuanX提交编程题(0.69 分)47.编写一程序实现以下功能根据输入的n(约定10n0)在屏幕上显示对应的图案,图案有四个分支,分支长度为n 个字符。程序的运行效果应类似地如图所示,图中的3 和 5 是从键盘输入的内容。please input the nOutput:(?ee(?ee ee ePress any key to continueplease input the n:5Output:0(?e ee e(?eee(?e ee ee ePress any key to continueX提交编程题(0.69 分)48.编 写 一 个 简 单 计 算 器 程 序,输 入

41、 格 式 为:datal op data2.其中datal和data2是参加运算的两个数(datal、data2必须定义为int,但二者札I加可能超出int能表示的范围),op为运算符,它的取值只能是+、-、*、/、%。编程可用素材:printf(Please input datal op data2:printf(nError!chu shuwei 0.n).o程序的运行效果应类似地如图1、图2、图 3、图4 所示,图 1 中的3000+2000、图2 中的3000%2000、图3 中的3000%0 和图4 中的3000/0 是从键盘输入的内容。6:D:c语言731Debuguyan4.ex

42、e”Please input datal op data2:3000+2000Output:3000+2000=5000Press any key to continuePlease input datal op data2:3000X2000Output:3000X2000=1000Press any key to continuec D:c语舌7 3 1 D e b u g iy a n 4.exe”Please input datal op data2:3000%0 flOutput:HError chu shu wei 6.MPress any key to continue Hc:D

43、:c语言731D ebugsiyan4.exePlease input datal op data2:3000/0Output:Error?chu shu wei 0.Press any key to continue._X提交编程题(0.69 分)49.根据输入的n(约定n0)在屏幕上显示对应的图案。编程可用素材:printf(,lnput:nM);printf(MnOutput:nM);.o程序的运行效果应类似地如图1 和图2 所示,图 1 中的3 和图2 中的5 是从键盘输入的内容。“工:程序设计基础D e b u g V t.e x eI n p u t :O u t p u t :$

44、.转 工:程序设计基础D e b u g t.exeI n p u t :O u t p u t:$.$X提交编程题(0.69 分)50.求 S=1/1!+1/2!+1/3!+.+1/N;并输出结果(显示时小数部分占6位,计算时要求从第1项开始往后累加)。N为任意自然数(只考虑int型),从键盘读入。编程可用素材:printf(Please input n:).、printf(nS=1/1!+1/2!+.+1/.!=.o程序的运彳亍效果应类4以地如图1所示,图1中 的18是从键盘输入的内容。Input number:18Output:|S=1/1 +1/2+.+1/2?=1.718282Pre

45、ss any key to continue.X提交编程题(0.69 分)51.才艮据输入的 n在屏幕上显示对应的以#组成的菱形图案。编程可用素材:printf(MPlease inputn:程序的运行效果应类似地如图1和 图2所示,图1中 的1和 图2中 的5是从键盘输入的内容。Pleas input n:1Output:#升Press any key to continue.|Plase input n:5Output:升#Press any key to continueX提交编程题(0.69 分)52.求 任 意 的 一 个 m x m 矩阵的最大数及其所在的行列数,m(2=m=20)

46、及矩阵元素从键盘输入(只考虑 int 型)。编程可用素材:printf(nmax=.,i=.,j=.n.o程 序 的 运 行 效 果 应 类 似 地 如 图 1 所示。提交编程题(0.69 分)53.求任意的一个mxm矩阵的两条对角线上元素之和,m(2=mv=20)及矩阵元素从键盘输入(只考虑int型,且不需考虑求和的结果可能超出int型能表示的范围,每个元素上的值只计算一次)。编程可用素材:printf(Please input m:).、printf(nPlease input array:rT).、printf(,nsum=.n,).程序的运行效果应类似下图,51 4 5 6 7 2 3

47、 5 4 6 43 5 6 8 9 3 2 3 4 2 83 4 7 9 3 4 6 4 7 9 5 7 4 64 6 7 8 5 4 3 6 1 9 4 3 4 6 3 43 2 3 5 5 6 7 2 4 8 4 6 5 2 5是从键盘输入的内容。3lease input m:53lease input a rra y:1 45 67 235 46435 6 89 32342 8347 9346 47 95 74646 785 436 19434 6343235 567 24 8465 25Output:sum=56339X提交编程题(0.69 分)54.程序的功能是:输入3 行 3 列的

48、矩阵,输出所有元素的累加和。程序的运行效果应类似地如图1 所示,图 1 中的9 20 1316 51 792 56 94是从键盘输入的内容。提交编程题(0.69 分)55.从键盘上读入一行字符(约定:字符数27),判断其中的注释是否合法,不合法则报错ncomment is e rro rn,合法时则删除注释后再输出,无注释则原文输出.合法注释是指“/*”标记注释开始、“*/”标记注释结束,通常表现为/*7.注意事项:(1)程序中不能使用库函数strstr或使用同名的变量、函数、单词。(2)只考虑行内最多只包含一个注释的情况。(3)不合法的注释情况有彳艮多种,例 如*/缺注释开始标记、/*缺注释

49、结束标记。(4)编程可用素材:printf(*lnput.printf(Hncomment is errorn).程序的运行效果应类似地如图所示.Input:I am a/xtru */studentOutput:I am a studentX提交编程题(0.69 分)56.程序的功能是:从键盘输入一行可带空格的字符串(约定:字符数V127字节),按逆序输出该字符串。注意,程序中不能使用库函数strrev或使用同名的变量、函数、单词。程序的运行效果应类似地如图1 所示,图 1 中的a be xyz是从键盘输入的内容。Input a string:abc xyzOutput:zyx cba提交编

50、程题(0.69 分)57.程序的功能是:有五个学生,每个学生的数据包括学号、姓名(最长19字节)、三门课的成绩,从键盘输入五个学生的数据,并计算每个学生的平均成绩,最后显示最高平均分的学生的信息(包括学号,姓名,三门课的成绩,平均分数)。要求用结构体编程,变量数据类型的选择应适当,在 保 证 满 足 设 计 要 求 精 度 的 情 况 下,养 成 不 浪 费 内 存 空 间 和 计 算 时 间 的 好 习 惯。编 程 可 用 素 材:printf(Please input students infb:nNum Name score 1 score?score3n).o程序的运行效果应类似地如图

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com