历年C语言上机真题

历年C语言上机真题

ID:83391357

大小:1.35 MB

页数:13页

时间:2023-07-15

上传者:灯火阑珊2019
历年C语言上机真题_第1页
历年C语言上机真题_第2页
历年C语言上机真题_第3页
历年C语言上机真题_第4页
历年C语言上机真题_第5页
历年C语言上机真题_第6页
历年C语言上机真题_第7页
历年C语言上机真题_第8页
历年C语言上机真题_第9页
历年C语言上机真题_第10页
资源描述:

《历年C语言上机真题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

ஹᦋ┯⚪1ஹᑡᐭᐸᜧᑏᦪm!ᑏᦪn,$%&m,nḄ(ᜧὅ஺#include"stdio.h"#include"string.h"main(){chars[80];inti,k,m=0,n=0;gets(s);i=1;/*$ERR0R1$*/k=strlen(s);while(i<=k)/*$ERR0R2$*/{if(s[i]>=,A1&&s[i]<=f7!)m++;elseif(s[i]>=,a*&&s[i]<=,z*)n++;i++T}if(n>m)/*$ERR0R3$*/printf("max=%d

1”,m);elseprintf("max=%d

2”,n);)2ஹ\Ḅ]^᦮ᦪḄᨬᜧabᦪ஺main(){intm,n,r,t;printf(zInputtwonumber,please!

3z);scanf("%d,%d",&m,&n);if(m>n)/*$ERR0R1$*/{t=m;m=n;n=t;}r=m%n;while(r==0)/*$ERR0R2$*/{m=n;n=r;r=m%n;)printf("gcd=%D

4”,n);/*$ERR0R3$*/}3ஹ\Ḅg&ᦪhḄᨬᜧᐗjkᐸ᪗m஺main(){inta[10]=(0,-3,9,2,5,4,8,7,6,1);/*$ERR0R1$*/inttmax,i;fmax=a[0];t=1;/*$ERR0R2$*/i=1Twhile(i<=10)/*$ERR0R3$*/{if(maxmain()tinta[10],*p;for(p=a;p

5scanf("%d”,p);p=a+10;/*$ERR0R1$*/for(;p>a;p)/*$ERR0R2$*/printfp);/*$ERR0R3$*/}5ஹᐭ10ᦪ⌱&ᐸḄᨬᜧᦪ஺main(){inti,max,a[10];printf(zinput10number:

6z);i=0;while(i<=10)/*$ERR0R1$*/{scanfa[i]);/*$ERR0R2$*/i++T)max=a[0];for(i=1;i<10;i++)if(a[i]>a[0])/*$ERR0R3$*/max=a[i]gprintf("maxnum=%d

7”,max);16ஹ&\(*ᨵ*ᨵ)************main()tinti,j;i=1;/*$ERR0R1$*/whiIe(i<4){j=0;while(j

8");i++T)i=3TwhiIe(i>0)(j=1Twhile(j<=i){printf("*");j++;}printf("

9");i++;/*$ERR0R3$*/117ஹᑭᵨ]g1/3-2/5+3/7-4/9+……+n/(2n-1)dḄm஺(⚪]50⚗)main(){inti=1;floats;s=0;while(i<50)/*$ERR0R1$*/{if(i%2=0)/*$ERR0R2$*/2

10s=s+1.0*i/(2*i+1);eIses=s-1.0*i/(2*i+1);i++T)printf("S=%d”,s);/*$ERR0R3$*/)8ஹ&\(&ᦪᦪᨵ)123345456756789mainO{inti,j;i=1Twhile(i<5)/*$ERROR1$*/(for(j=i;j<2*i;j++)printf(z%fz,j);/*$ERROR2$*/printf("

11");i—;/*$ERROR3$*/9ஹᑭᵨ]g(⚪]20⚗Ḅ)S=1/(1*2*3)-1/(2*3*4)+1/(3*4*5)-.....+1/(19*20*21)-1/(20*21*22)main()linti;fIoats;/*$ERR0R1$*/i=1Twhile(i<20)/*$ERR0R2$*/{if(i%2=0)/*$ERR0R3$*/s=s+1.0/(i*(i+1)*(i+2));elses=s-1.0/(i*(i+1)*(i+2));i++T)printf("%f

12”,s);)10ஹ\Ḅg¡mean¢ᦪ]numᦪḄ£ᙳmᙠ¦¢ᦪ§ᵨmean¢ᦪ]15ᦪḄ£ᙳm$&¨©஺#incIudefloatmean(intx,intnum)/*$ERR0R1$*/{inti;floatavg;for(avg=0,i=0;i

13a[i]=i+3;avg=mean(a[0],15);/*$ERR0R3$*/printf("average:%6.2f

14”,avg);)11ஹ\¡«¬81Ḅᦪhᵨ®¯°ᑨ²ᐭḄᔲ“µᦻ”(ᓽ¸¹᎔¹»᪵½᝞:ABCBA,✌ÂÃÂḄÄÅÆÇ(஺)#incIude#includemainO{chars[81];/*$ERR0R1$*/inti,j,n;scanf("%s”,s);n=strlen(s);i=0;j=n-1;/*$ERR0R2$*/while(sU]='')i++;while(s[j]—')j—;while(i

15");eIseprintf("Yes

16");112ஹ☢Ḅ¦¢ᦪᐭÍ᦮ᦪn,$xy§ᵨfac¢ᦪ]ÎnḄ▤Ðᙠ¦¢ᦪ&n!Ḅm,ÑÒᦋḄ┯Ó஺#incIudeIongfac(intn){inti;longs;s=1;/*$ERR0R1$*/i=1Twhile(i<=n)/*$ERR0R2$*/{s=s*i;i++;}returns;1main(){intn;printf("Entern:");scanf("%d",&n);/*$ERR0R3$*/printf("s=%Id

17”,fac(n));}13ஹÔᦪhḄᦪᢥᜧᑮ!᣸Ø&(&Ùᦪᓰ5ÛDmain(){inta[10]={23,90,-45,60,100,62,78,-89,-50,0);inti,j,temp;for(i=0;i<9;i++)(for(j=0;j<9-i;j++){if(a[j]

18}for(i=0;i<=9;i++)printf("%5d”,a[i]);/*$ERR0R3$*/114ஹÄᵨstrcat¢ᦪÔᐭḄ^ÜÝÞᩭᡂá(ÔâÜÝᑮḄØ☢)#incIudemain(){chars1[60],s2[30];inti=0,j=0;printf("Entertwostring:

19");scanf("%s%s”,s1,s2);/*$ERR0R1$*/for(i=0;s1[i]!='\0';i++);/*$ERR0R2$*/while(s2[j]='\0')/*$ERR0R3$*/Is1[i]=s2[j];i++Tj++T)s1[i]='\0';printf(w

20Newstring:%s

21”,s1);115ஹ\ᑨ²ᐭḄᔲ“µᦻ”(ᓽ¸¹᎔¹»᪵஺½᝞gABCBA,✌ÂÃÂḄÄÅÆÇ()஺#include#includemain(){chars[81];inti,j,n;gets(s);n=strIen(s);i=0;/*$ERR0R1$*/j=n-1Twhile(s[i]='')i++;while(s[j]—')j—;while(i

22");eIseprintf("Yes'n");)âஹä⚪1ஹᑡ&200—300ḄᐰÂjᦪḄÑä஺#includemainOlinti,j,f,s;s=0;/*$BLANK1$*/for(i=201;i<300;i+=2)gTfor(j=2;j

23if(j>=l-1)s+=i;/*$BLANK3$*/1printf("s=%d

24”,s);12ஹᐭ10ᦪ¯ᐭᦪhaᦪh᪗᜻ᦪ%ᦪhᐗjmᏔᦪḄᐗjᦪ஺#includemain()linta[10],i,s;s=0;/*$BLANK1$*/for(i=0;K10;i++)/*$BLANK2$*/{scanf("%d”,&a[i]);if(i%2==1&&a[i]%2=0)/*$BLANK3$*/s++;)printf("%d

25”,s);)3ஹéᗐë5*5ᦪhḄ¦ìíᐗj1,ᐸîᐗj0஺main()(intj,k,a[5]মTfor(j=0;j<5;j++)for(k=0;k<5;k++){if(k=j)/*$BLANK1$*/a[j][k]=1;/*$BLANK2$*/eIsea[j][k]=O;/*$BLANK3$*/)for(j=0;j<5;j++){for(k=0;k<5;k++)printf("%d",a[j][k]);printf("

26");1)4ஹ\ᐭ(\µð¨ñᐭ)ᐸᡠᨵᦪḄᦪ஺#incIude“stdio.h"main(){charch;ints=0;ch=getchar0Twhile(ch!=,

27,)/*$BLANK1$*/{if(ch>='O'&&ch<='9')/*$BLANK2$*/s++Tch=getchar();/*$BLANK3$*/)printf("%d

28”,s);15ஹ\¦¢ᦪ§ᵨcolurmiin¢ᦪóôᙠNMᑡḄâõᦪhö&ᑡ÷Ḅᨬ!m஺#defineN3#defineM4voidcolummin(intx[N][M]){inti,j,p;for(j=O;j

29if(x[p][j]>x[i][j])p=i;/*$BLANK1$*/printf("Theminincolum%dis%d

30z,j,x[p][j])g/*$BLANK2$*/1}mainO{intx[N][M]={1,5,7,4,2,6,4,3,8,2,3.11;coIummin(x);/*$BLANK3$*/)6ஹᑡóôÝù3ᦪ&ᨬᜧᦪᨬ!ᦪéᗐ஺᝞g#incIudemain(){inta,b,c,*pmax,*pmin;printfCinputthreenumbers:

31z);scanf("%d%d%d",&a,&b,&c);if(a>b){pmax=&a;pmin=&b;}eIse{pmax=&b;pmin=&a;}if(c>*pmax)pmax=&c;/*$BLANK1$*/elseif(c<*pmin)pmin=&c;/*$BLANK2$*/printf("max=%d,min=%d

32",*pmax,*pmin);/*$BLANK3$*/)7ஹ\Ḅgᵨ0-9ÄúḄûᦪ᪀ᡂûýᦪᨵþÿ᝞123,345,182mainO{inti,j,k,count;count=0;/*$BLANK1$*/for(i=1;i<=9;i++)for(j=0;j<=9;j++)if(l==j)continue;/*$BLANK2$*/elsefor(k=0;k<=9;k++)if(k!=l&&k!=j)count++;/*$BLANK3$*/printf("%d”,count);}8ஹ<=ᦪ=1*1+2*2+3*3+4*4+...+n*n,<@n⚗BCDE50000FḄᨬᜧḄnḄJs#incIudemainOlinti,n,s;s=0;/*$BLANK1$*/i=1Owhile(s<=50000)(s+=l*i;/*$BLANK2$*/i=i+1;1n=l-1;/*$BLANK3$*/printf("n=%d",n);)9ஹRSTUVW(ᦪXBYZᨵ\]^_`aᦪX@bZᨵ\)000100000111007

3301111101111111011111000111000001000#includemainOlinti,j;for(i=-3;i<=3;i++){j=1Owhile(j<=abs(i))/*$BLANK1$*/(printf("0");j++;)j=1Owhile(j<=7-2*abs(i))/*$BLANK2$*/{printf(T);j++;)j=1while(j<=abs(i))/*$BLANK3$*/(printf(w0w);J++;}printf("

34");})10ஹTUhiḄjkl

35z);scanf("%d,%d",&m,&n);if(m0){r=m%n;m=n;n=r;/*$BLANK2$*/)printf("gcd=%d

36”,m);/*$BLANK3$*/)11ஹTUhiRᐭ`^Xz(T{|}~Rᐭ)ᯠᐸtᡠᨵXz'2ᣚᡂXz▕#include#includemain(){chars[80];inti;gets(s);l=0;/*$BLANK1$*/while(s[i]!=,\0,)/*$BLANK2$*/{if(s[i]='b')s[i]='f';I++;/*$BLANK3$*/)printf("%s

37",s);8

3812ஹUᑡhiᦈ3aᦪRSᨬᜧᦪCᨬDᦪᗐhi஺#incIudemainO{inta,b,c,*pmax,*pmin;printf(zinputthreenumbers:

39z);scanf("%d%d%d”,&a,&b,&c);if(a>b){pmax=&a;pmin=&b;}else{pmax=&b;pmin=&a;}if(c>*pmax)pmax=_;/*$BLANK1$*/elseif(c<*pmin)pmin=_;/*$BLANK2$*/printf(zmax=%d,min=%d

40",___);/*$BLANK3$*/)13ஹᦈ20a᦮ᦪᐸtᦪḄaᦪTᡠᨵᦪBC஺#incIudemainO{inti,a[20],count;longsun=0;for(i=0;i<20;i++)scanf&a[i]);/*$BLANK1$*/count=0;/*$BLANK2$*/for(i=0;i<20;i++)(if(a[i]>0){sun+=a[i];count++O/*$BLANK3$*/))printf("%d,%Id”,count,sun);)14ஹTUhiḄᦪ¡¢\Ḅ£ᦪ¤RS¢\Ḅ¥¦஺(num§¨⊤ªname§¨⊤«¬scroe§¨⊤ᡂ)structstu{intnum;charname[12];floatscore;)Omain(){structstustud[5]={{101,“Liping”,45},/*$BLANK1$*/{102,zzZhangping”,62.5},{103,“Hefang”,92.5},{104,“ChengIing”,87),{105,“Wangming”,58}};inti,n=0;printf(znum\tname\tscore

41z);i=0;whiIe(i<5)(if(stud[i].score<60)/*$BLANK2$*/{printf("%d\t%s\t%.2f

42”,stud[i].num,stud[i].name,stud[i].score);n++;/*$BLANK3$*/)i++O9

43)printf("n=%d

44”,n);!ஹ³h⚪1ஹhiµᑭᵨU☢o¹PRINT(floats){FILE*out;if((out=fopen("C:\\24000101\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%f",s);fcIose(out);)main(){fIoats;PRINT(s);)2ஹ`aÁᯠᦪ◀T2Ã1,◀T3Ã2,◀T4Ã3,◀T5Ã4,◀T7Ã5,<ÄÅÆaᩩÈḄᨬDḄÁᯠᦪ஺RS\¹n=23#includePRINT(intn){FILE*out;if((out=fopen("C:\\24000101\\RESULT.TXT","w+"))!=NULL)fprintf(out,n=%dn);IfcIose(out);)main(){intn;PRINT(n);}3ஹ³ᑏhiÊ500ᑮ1300BYᡠᨵÌkÍ7᦮◀ÎkÍ13᦮◀ḄÁᯠᦪBC஺RS\¹26஺#includePRINT(ints){FILE*out;if((out=fopen("C:\\24000103\\RESULT.TXT","w+"))!=NULL)fprintf(out,"%d”,s);fclose(out);)main()PRINT(s);)4ஹRS100--300BYḄᐰÐÑᦪḄC஺#incIudePRINT(ints){FILE*out;if((out=fopen("C:\\24000101\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fcIose(out);)main()10

45PRINT(s);15ஹ³ᑏhiÊs=1+1/(1*2)+1/(1*2*3)+1/(1*2*3*4)+….+1/(1*2*3*...*n)ḄJ஺ÓÔÕ⚪Tn=10Ö×஺RS\¹s=1.123456#includePRINT(floats){FILE*out;if((out=fopen("C:\\24000108\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%f",s);fcIose(out);)mainO{fIoats;PRINT(s);)6ஹ<ᡠᨵḄ“ØÙÚᦪ”BC஺ᡠÛ“ØÙÚᦪ”lᢣ`aÝÞᦪᐸᔜÞᦪXḄàCEáᦪÕâ஺×᝞“153”l`a“ØÙÚᦪ”ãÖ153=1*1*1+5*5*5+3*3*3஺RS\¹23456#includePRINT(ints){FILE*out;if((out=fopen("C:\\24000107\\RESULT.TXT","w+"))!=NULL)fprintf(out,"%d”,s);fcIose(out);)main()(PRINT(s);}7ஹᙠᜧE500ḄÑᦪtRS@5aÑᦪḄCRS\¹s=23516#incIudePRINT(ints){FILE*out;if((out=fopen(zK:\\24000104\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fcIose(out);1mainO{ints=0;PRINT(s);18ஹᨵmaDE40Ḅ᦮ᦪaCb,aḄäåbḄCl1053,bḄäåaḄCl873,³h<ÄÅᩩÈḄaCbḄJ஺(æçÄÅᩩÈḄa,bḄJè`)RS\¹a=3,b=4#incIudePRINT(inta,intb){FILE*out;if((out=fopen("K:\\24000108\\RESULT.TXT","w+"))!=NULL)11

46fprintf(out,za=%d,b=%d”,a,b);fcIose(out);)mainO(inta,b;PRINT(a,b);)9ஹ᪷¡Uᑡo¹ÊA30ḄJ஺(ê◤ìᵨíî)A1=1,A2=1,A3=3/(A2+A1),A4=4/(A3+A2),....A30=30/(A29+A28)RS\¹A30=7.235167#incIudePRINT(floatf){FILE*out;if((out=fopen("C:\\24000114\\RESULT.TXT",஻w+஻))!=NULL)fprintf(out,"A3O=%f”,f);fcIose(out);}main(){PRINT(s);)10ஹÊ200ᑮ700BYᡠᨵkÍ“᦮◀Ḅ᜻ᦪBC஺#incIudePRINT(ints){FILE*out;if((out=fopen(ZC:\\24000145\\RESULT.TXTZ,zw+z))!=NULL)fprintf(out,"%d”,s);fcIose(out);)mainO{PRINT(s);}11ஹñẈó⚪஺36£ñô6ᙽẈᵱ£1£ñ3ᙽẈ᝕£1£ñ2ᙽDø3£ñ1ᙽ஺ᵱ£ஹ᝕£ஹDøùêúᨵûᔜᨵü£ý(ᵱ£ஹ᝕£ஹDøᦪþᙳ0,ᫀḄ஺)ᐭmen=3,women=4,child=5#includePRINT(inta,intb,intc){FILE*out;if((out7fopen('C:\\24000116\\RESULT.TXT",஻w+஻))!=NULL)fprintf(out,"men=%d,women=%dchiId=%d”,a,b,c);rfcIose(out);)mainO{inta,b,c;PRINT(a,b,c);)12ஹLM᤺OP᪻RSᓬᣵVSWᔛYZ[\]7ᜩᓬᣵᒕOḄVSWᔛYZ[\]`ᜩஹ]aᜩஹ]bᜩஹ]cᜩஹ]dᜩef᝞hiᳮS]ᓝcᜩlSmnoᒕ`[᪻RY஺pᑏrsSthMᐳ᤺Yvw[᪻Rx#includePRINTdongs){FILE*out;if((out=fopen(ZSC:\\24000147\\RESULT.TXTSZ,z/w+zS))!=NULL)fprintf(out,"%Id”,s);fcIose(out);12

47}main()(PRINT(s);}13ஹᑭᵨO☢tsḄ(t50⚗)S=1/3-(2/5)+(3/7)-(4/9)+(5/11)-(6/13)+...+(49/49)+50/101:s=0.123456#includePRINT(floats){FILE*out;if((out=fopen("C:\\24000101\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%f",s);fcIose(out);1main()(PRINT(s);114ஹᦪ10000037ḄᦪStᩩḄᨬḄᦪ஺#includePRINT(intn){FILE*out;if((out=fopen("C:\\24000135\\RESULT.TXT","w+"))!=NULL)fprintf(out,"n=%d",n);fcIose(out);1main(){intn;PRINT(n);}15ஹᙠᜧ500ḄᦪS5ᦪḄs=23516#incIudePRINT(ints){FILE*out;if((out=fopen(ZSK:\\24000104\\RESULT.TXT","w+"))!=NULL)fprintf(out,"s=%d",s);fcIose(out);1main(){ints=0;PRINT(s);)13

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
最近更新
更多
大家都在看
近期热门
关闭