好文档 - 专业文书写作范文服务资料分享网站

C语言1

天下 分享 时间: 加入收藏 我要投稿 点赞

《C语言》综合复习资料

第一题 读程序写出程序执行结果 1、 #include <stdio.h> void main() { int x[]={1,2,3}; int s=1,i,*p=x; for(i=0;i<3;i++) s*=*(p+i); printf(“%d\\n”,s); }

2、#include <stdio.h> int fun(char *s1,char *s2) { int i=0;

while(s1[i]==s2[i] && s2[i]!='\\0') i++; return (s1[i]=='\\0' && s2[i]=='\\0'); }

void main()

{ char p[10]= \ printf(\}

3、#include <stdio.h> \ { int n=2;

printf(“%d,%d,%d\\n”, ++n , n+=2 , --n) ; }

4、#include <stdio.h> void main() { int x=1,a=0,b=0; switch(x) { case 0: b++; case 1: a++; case 2: a++;b++; }

printf(“a=%d,b=%d\\n”,a,b);

}

5、#include <stdio.h> void main()

{ int s,t,a=-2,b=6; s=t=1; if(a>0) s=s+1; if(a>b) t=s+t; else if(a==b) t=5; else t=2*s;

printf(\}

6、#include <stdio.h> #define S(a,b) (a)*(b) void main() { int a=3 ,area; area=S(a,a+3) ;

printf(\; }

7、#include <stdio.h> void main() { int i=0,a=0; while( i<20 ) { for(;;)

if((i)==0) break; else i--; i+=11; a+=i; }

printf(\}

8、#include <stdio.h> void swap(int b[]) { int *p,*p1,*p2;

p1=&b[0] ;p2=&b[1];

p=p1; p1=p1+1; p2=p; }

void main() { int a[]={5,9};

printf(\; swap(a);

printf(\; }

9、#include <stdio.h> fun(int a, int b) { if(a>b) return(a); else return(b); }

void main()

{ int x=3, y=8, z=6, r; r=fun(fun(x,y), 2*z); printf(\}

10、#include <stdio.h> int fun(int x) { int y=1; static int z=4; z =1; y; return(x y z); }

void main() { int i; for(i=1;i<=3;i ) printf(\}

11、#include <stdio.h> void fun(char *w, int n) { char t, *s1, *s2; s1=w; s2=w n-1;

while(s1

*s2= t}

void main()

{ char p[]=\; fun(p, strlen(p)); puts(p); }

12、#include <stdio.h> char fun(char *s)

{ if( *s >= ¢a¢ && *s <= ¢z¢ ) *s=*s-32; return *s; }

void main()

{ char a[20]=\for(p=a;*p!=¢\\0¢;p ) { ch=fun(p); putchar(ch); } }

13、#include <stdio.h> void main() { int a=10,b=0; if(a==12) {a++; b++; } else

{ a=a+3 ; b=b+3;} printf(“%d,%d\\n”,a,b); }

14、#include <stdio.h> void main() { int s,i;

for(s=0,i=1;i<5;i++,s+=i) ; printf(“%d\\n”,s); }

15、#include <stdio.h>

void main() { char n=‘c’; switch(n )

{ default: printf(“error!”); break; case ‘a’: case ‘A’:

case ‘b’: case ‘B’: printf(“good!”);break; case ‘c’: case ‘C’: printf(“pass!”); case ‘d’: case ‘D’: printf(“warm!”); } }

16、#include <stdio.h> void main() { int k=4,n=0; for( ; n

if(n%3!=0) continue; k- -; }

printf(\; }

17、#include <stdio.h> int f(int b[],int m,int n) { int i,s=0;

for(i=m;i<=n;i+=2) s+=b[i]; return s; }

void main()

{ int x,a[]={1,2,3,4,5,6,7,8,9,10}; x=f(a,3,8); printf(“%d\\n”,x); }

18、#include <stdio.h>

void copy_str(char from[ ],char to[ ]) { int k=0;

while(from[k]!=‘\\0’)

C语言1

《C语言》综合复习资料第一题读程序写出程序执行结果1、#include<stdio.h>voidmain(){intx[]={1,2,3};ints=1,i,*p=x;for(i=0;i<3;i++)s*=*(p+i);printf(“%d\\n”,s);}2、#
推荐度:
点击下载文档文档为doc格式
2n77y6dn309sc9l3qd1d
领取福利

微信扫码领取福利

微信扫码分享