资源描述:
《C语言程序设计期末复习题(分析程序或程序段)新教程文件.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、精品好文档,推荐学习交流第三部分分析程序或程序段分析程序或程序段,给出下列程序的运行结果:仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流1.#includemain(){inti=16,j,x=6;j=i+++1;x*=i=j;printf(“%d,%d”,j,x);}运行结果是:2.#includemain(){inta,b,c,d;a=c=0;b=1;d=20;if(a)d=d-10;elseif(!b)if(!c)d=25;elsed=15;printf(“d=%d”,d);}运行结
2、果:3.main(){inti=10;switch(i){case9:i+=1;case10:i+=1;case11:i+=1;default:i+=1;}printf(“%d”,i);}运行结果:4.#includemain(){inta[]={1,2,3,4},i,j,s=0;j=1;for(i=3;i>=0;i--){s=s+a[i]*j;j=j*10;}printf("s=%d",s);}运行结果:5.func(intx){x=20;}main(){intx=10;func(x);printf(“%d”,x);}运行结果:1
3、06.#includemain(){intx=8,y=12;printf("%d%d",x++,++y);printf("%d%d",x,y);}运行结果是:7.#includevoidFunc(intb[]){intj;for(j=0;j<4;j++){b[j]=j;}仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流}main(){staticinta[]={5,6,7,8},i;Func(a);for(i=0;i<4;i++){printf("%d",a[i]);}}运行结果是:8.
4、#includemain(){intcube(inty);intx;for(x=1;x<=5;x++)printf(“%d”,cube(x));}intcube(inty){return2*y;}运行结果是:9.#includevoidFunc(void);main(){inti;for(i=0;i<2;i++){Func();}}voidFunc(void){staticinttimes=1;printf("Func()wascalled%dtime(s).",times++);}运行结果是:10.#includ
5、e#include#defineARR_SIZE80voidInverse(charstr[]);main(){chara[ARR_SIZE];printf("Pleaseenterastring:");gets(a);Inverse(a);printf("Theinversedstringis:");puts(a);}voidInverse(charstr[]){intlen,i=0,j;chartemp;len=strlen(str);for(j=len-1;i6、r[j]=str[i];str[j]=temp;}}仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流运行时键盘上输入ASDFG,结果是:11.#includevoidFunc(void);main(){inti;for(i=0;i<5;i++){Func();}}voidFunc(void){staticinta=1;intb=2,c;c=a+b;a++;b++;printf("%3d",c);}运行结果是:12.#includeintfun(intx,inty){returnx>y?x:y;}ma
7、in()仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流{inta=2,b=5,c=8;printf("%d",fun(fun(a+c,b),a-c));}运行结果是:13.main(){inti,j,x=0;for(i=0;i<2;i++){x++;for(j=0;j<3;j++){if(j%2)continue;x++;}x++;}printf("x=%d",x);}运行结果是:14.#includeintfun1(intx){x=20;returnx;}voidfun2(intb[4]){intj;fo
8、r(j=3;j>=0;j--){b[j]=j;}}main(){inty,x=1