您现在的位置:首页 > 建筑/土木 >

桂林电子科技大学C语言程序设计习题集及答案




37

2 44

1 C A C

B C

C C

D

2 C B

A C

2 44

1 C

A C

B C

C C

D

2 C B

A

B main

C

D

3 C B

A a=b=58

B i++;

C a=58,b=58

D k=int(a+b);

4 B

A 1abc

B include

C a-b-c123

D char

5 C A

A 0x10

B 0976

C 076L

D 01ff

6 C A

A%

B ++

C/

D=

7 a b int B

int a=20; int b=3; printf("%d\n",a+=(b%=2));

A 20

B 21

C0

D 23

8 int i; i=2.6;i A

A2

B3

C 2.6

D

9 D

A 'ab'

B '\482'

C '\'

10 y int y C

D '\xaf'

y=8; y+=y-=y*y;

A 64

B 56

C 112

D 48

11 D

A e-3

B 1.5e+2.4

C 3.14e+2L

D 3.14 e +5

12 int float double 8

float a=2;int b=3;A

printf("%d",sizeof(a*b)+2/5);

A4

B8

C6

D7

13 int 2 int i=-2;, printf("%u",i);C

A0

B -2

C 65534

D 65535

14 xyz a=100 z A

x=a++; y=--a; z=x+y-a--;

A 100

B 400

C 200

D 300

15 int u=010,v=0x10,w=10,printf("%d,%d,%d\n",u,v,w); A

A 8,16,10

B 10,10,10

C 8,8,10

D 8,10,10

16 xy int y A

x=5; y=x++*x++; y=--y*--y;

A 529

B 2401

C 1209

D 625

17 a,b,c 1

1 D abc

A 1/a*b*c

B 1/(a*b*c)

C 1/a/b/(float)c D 1.0/a/b/c

18 int a=8,b=5,c;char d='A'; c=a/b+d%a+0.5; c A



A2

B 2.5

C3

D

19

main()

{ int i=10,j=1;

i=i+j++;

printf("%d,%d,%d\n",i++,++j,i);

}

C

A 12,3,11

B 12,2,11

C 11,3,11

D 12,3,12

20 int i=65; putchar(i);printf("%d",i);printf("%c",i);A



A A,65,A

B 65,65,A

C A,A,65

D A,A,A

21 int y,a,i=1; printf("%d,%d",-i++,(y=a=3.6*3));A

A -1,10

B -2,1.8

C 0,3

D 1,18

22

main()

{ char a,b,c,d;

a='\'; b='\xbc';

c='\0xab'; d='\023';

printf("%c%c%c%c\n",a,b,c,d);

}

A

A a='\';

B b='\xbc';

C d='\023';

D a='\'; c='\0xab';

1 2 3 56 1 x int ,"x "x%2==0 2 scanf("a=%d,b=%d,c=%d",&a,&b,&c); 234 abc a=2,b=3,c=4 3 int a=3; a+=a-=a*a a -12 4 10 6 main() { int a=-10,b=-3; printf("%d\n",-a++); printf("%d\n",-a+b); } 5 242 main() { char c;

c=0362; printf("%dn",c); } 6 n 3276732767 int m=32767,n=032767; printf("%d,%o\n",m,n); 7 "\\name\\\101ddress\b\xaf"15 8 int m=0,n=0; char c='a'; scanf("%d%c%d",&m,&c,&n); printf("%d,%c,%d\n",m,c,n); 10A10<>10,A,10 9 main() { printf("%d,%o,%x\n",10,10,10); printf("%d,%d,%d\n",10,010,0x10); printf("%d,%x\n",012,012); } 10 abc a=2b=3c=4 a*=16+(b++)-(++c); a 28 11 12 main() { int x=023; printf("%x\n",--x); } 12 main() { int a=2,b=3,c,d; c=(a++)+(a++)+(a++); d=(++b)+(++b)+(++b); printf("a=%d c=%d\n",a,c); printf("b=%d d=%d\n",a,d); } 13 main() { char ch1,ch2,ch3; scanf("%c%c%c",&ch1,&ch2,&ch3); printf("%c%c%c%c%c",ch1,'#',ch2,'#',ch3); } ABC 1 A BC 2 14 float x;, x=5.16894; printf("%f\n",(int)(x*1000+0.5)/(float)1000); 15 main()

{ char ch;

1

/* */

2

/* */

3

/*

*/

}

16 9876543210,



main()

{ int a; float b,c;

scanf("%2d%3f%4f",&a,&b,&c);

printf("\na=%d,b=%f,c=%f\n",a,b,c);

}

17

main()

{ printf("%12.5f\n",123.1234567);

printf("%12f\n",123.1234567);

printf("%12.8d\n",12345);

printf("%12.8s\n","abcdefghij");

}

18 abcdefg,

main()

{ char ch1,ch2,ch3;

ch1=getchar(); ch2=getchar(); ch3=getchar();

putchar(ch1); putchar(ch2); putchar(ch3);

putchar('\n');



19 a=3,b=535,35.12abc

main()

{ int a,b; float x,y; char c1,c2;

scanf("a=%d,b=%d",&a,&b);

scanf("%f,%e",&x,&y);

scanf("%c%c%c",&c1,&c1,&c2);

printf("a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%c\n",a,b,x,y,c1,c2);

}


2 40
1 B
main() { int a=0,b=0;
a=10; b=20; printf("a+b=%d\n",a+b); }

A a+b=10

B a+b=30

C 30

2 C

main()

{ double d=3.2; int x,y;

x=1.2; y=(x+3.8)/5.0;

printf("%d\n",d*y); }

A3

B 3.2

C0

3 C

main()

{ double d; float f; long l; int i;

i=f=l=d=20/3

printf("%d %ld %.1f %.1f\n",i,l,f,d); }

A 6 6 6.0 6.0

B 6 6 6.7 6.7

C 6 6 6.0 6.7

4 D

main()

{ int a=1,b=2;

a=a+b; b=a-b; a=a-b;

printf("%d,%d\n",a,b); }

A 1,2

B 1,1

C 2,2

5 A

main()

{ int x,y,z;

x=y=2; z=3;

y=x++-1; printf("%d %d ",x,y);

y=++x-1; printf("%d %d\n",x,y);

y=z---1; printf("%d %d ",z,x);

y=--z-1; printf("%d %d\n",z,x);

}

A3143

B3133

C3143

2414

2422

2412

6 D

main()

{ int x,y,z;

x=y=1;

z=x++,y++,++y;

printf("%d,%d,%d\n",x,y,z);

}

A 2,3,3

B 2,3,2

C 2,3,1

7 D

main()

{ int x=4,y=7;

x-=y; y+=x;

D D 3.07 D 6 6 6.7 6.0 D 2,1
D2132 1312
D 2,2,1

printf("%d %d\n",x,y);

}

A4 7

B -3 -3

C -3 11

D -3 4

8 C

main()

{ unsigned short a=65536; int b;

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

}

A 65536

B0

C1

D -1

9

#include <stdio.h>

main()

{ char c1,c2,c3,c4,c5,c6;

scanf("%c%c%c%c",&c1,&c2,&c3,&c4);

c5=getchar(); c6=getchar();

putchar(c1); putchar(c2);

printf("%c%c\n",c5,c6);

}

( 1 )

123<>

45678<>

B

A 1267

B 1256

C 1278

D 1245

10 ab c int a=3,b=0,c=5, 0 C

A 'a'&&'b'

B a&&b||c

C a&&b&&c

D a||b&&c

11 if C else C

A if

B if

C else if

D if

12 if a 0 ,

D

A a<>0

B !a

C a=0

Da

13 C

main()

{ int a=2,b=-1,c=2;

if(a<b)

if(b<0) c=0;

else c++;

printf("%d\n",c); }

A0

B1

C2

D3

14 k int C

k=-3;

if(k<=0) printf("####")

else printf("&&&&");

A ####

B &&&&

C ####&&&&

D

15 A

main()

{ int a=0,b=0,c=0,d=0;

if(a=1) b=1;c=2;

else d=3;

printf("%d,%d,%d,%d\n",a,b,c,d);

}

A 0,1,2,0

B 0,0,0,3

C 1,1,2,0

D

16 A

main()

{ int x1=1,x2=0,x3=0;

if(x1=x2+x3) printf("****");

else printf("####");

}

A ****

B

C ####

D

17 a=1,b=3,c=5,d=4 x B

if(a<b)

if(c<d)x=1;

else if(a<c)

if(b<d)x=2;

else x=3;

else x=6;

else x=7;

A1

B2

C3

D6

18 D

A break switch

B switch default

C break switch case

D switch break

19 float x=1.5; int a=1,b=3,c=2; switch

A switch(x)

B switch((int)x)

{ case 1.0:printf("*\n");

{ case 1:printf("*\n");

case 2.0:printf("**\n"); }

case 2:printf("**\n"); }

C switch(a+b)

D switch(a+b)

{ case 1:printf("*\n");

{ case 1:printf("*\n");

case 2+1:printf("**\n"); }

case c:printf("**\n"); }

20

#include<stdio.h>

main()

{ int x=1,y=0,a=0,b=0;

switch(x)

{ case 1:

switch(y)

{ case 0:a++;break;

case 1:b++;break;

}

case 2:a++;b++;break;

}

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

}

A a=2,b=1

B a=1,b=1

C a=1,b=0

D a=2,b=2

3 30 1 #include <stdio.h> main() { int i=010 , j=10; printf("%d,%d\n",++i,j--); } 2 #include <stdio.h> main() { printf("%d%d%d\n",'\0','\0','\0'); } 3 main() { int i=5,j,k; j=i+++i+++i++; k=(++i)+(++i)+(++i); printf("i=%5d j=%5d\nk=%5d\n",i,j,k); } 4 9876543210<> main() { int a; float b,c; scanf("%2d%2f%2f",&a,&b,&c); printf("a=%d,b=%.1f,c=%.0f",a,b,c); } 5 main() { char ch1,ch2; ch1='A'+'5'-'3'; ch2='A'+'6'-'3'; printf("%d,%c\n",ch1,ch2); } 6 printf("%d\n",(a=3*5,a*4,a+5)); 7 main() { int x=10; printf("%d,%d\n",--x,--x); }

8 xyz, C 9
int x=3; if((x%2)?printf("**%d",x):printf("##%d\n",x)); 10 main() { int m=5;
switch(m/2) { case 1: m++;
case 2: m+=3; case 5: m+=6;break; default: m-=7; } printf("%d\n",m); }

5 30

1 16.00 main()

{ int a=9,b=2;

float x= 1 ,y=1.1,z;

z=a/2+b*x/y+1/2;

printf("%5.2f\n",z); }

2 a,b,c a,b,c

s p(p a)(p b)(p c) p a b c )

#include <stdio.h>

2

2 ;

main()

{ int a,b,c;

3

printf("please input the value of a,b,c") scanf("%d %d %d", 4 ); if( 5 )

{ 6

s=sqrt(p*(p-a)*(p-b)*(p-c));

printf("Yes,this is a triangle!\n the area is %.2f.\n",s); }

else printf("No,this is not a triangle!\n") }


2 40

1 while

main()

{ int i=0;

while(i<10)

{ if(i<1) continue;

if(i==5) break;

i++;

}

......

}

A1

B 10

C6

D

2

main()

{ int n=9;

while(n>6) { n--; printf("%d",n); }

}



A 987

B 876

C 8765

D 9876

3 while

int k=0;

while(k=1) k++;

A

B

C D 1

4

A do-while

B do-while break

C do-while while

D do-while while

5

main()

{ int a,y;

a=10; y=0;

do{ a+=2; y+=a;

printf("a=%d y=%d\n",a,y);

if(y>20) break;

}while(a=14);

}

A a=12 y=12

B a=12 y=12

a=14 y=16

a=16 y=28

a=16 y=20

a=18 y=24

C a=12 y=12

D a=12 y=12

a=14 y=26

a=14 y=44

6

main()

{ int x=23;

do{ printf("%d",x--); }while(!x);

}

A 321

B 23

C

7

int x=3;

do { printf("%d ",x-=2); }while(!(- -x));

A1

B3 0

C 1 -2

8

main()

{ int a=0,i;

for(i=1;i<5;i++)

{ switch(i)

{ case 0: case 3: a+=2;

case 1: case 2: a+=3;

default:a+=5;

}

}

printf("%d\n",a);

}

A 31

B 13

C 10

9

main()

{ int i=0,a=0;

while(i<20)

{ for(; ;)

if((i%10)==0) break;

else

i--;

i+=11; a+=i;

}

printf("%d\n",a);

}

A 21

B 32

C 33

10

main()

{ int i,j;

for(i=0,j=1;i<=j+1;i+=2,j--) printf("%d \n",i);

}

A3

B2

C1

11

main()

{ int i,j,m=0,n=0;

for(i=0; <2;i++)

for(j=0;j<2;j++)

if(j>=i) m=1;n++;

printf("%d\n",n);

}

D D
D 20
D 11 D0

A4

B2

C1

D0

12

main()

{ int i,sum;

for(i=1;i<=3;sum++) sum+=i;

printf("%d\n",sum);

}

A6

B3

C

D0

13 sum

main()

{ int i,sum;

for(i=1;i<6;i++) sum+=i;

printf("%d\n",sum);

}

A 15

B 14

C

D0

14

main()

{ int i,n=0;

for(i=2;i<5;i++)

{ do{ if(i%3) continue; n++; } while(!i);

n++;

}

printf("n=%d\n",n);

}

A n=5

B n=2

C n=3

D n=4

15 26

A for(a='a';a<='z';printf("%c",++a)); B for(a='a';a<='z';) printf("%c",a);

C for(a='a';a<='z';printf("%c",a++)); D for(a='a';a<='z';printf("%c",a));

16

main()

{ int x=1,y=1;

while(y<=5)

{ if(x>=10) break;

if(x%2==0)

{ x+=5; continue; }

x-=3; y++;

}

printf("%d,%d",x,y);

}

A 6,6

B 7,6

C 10,3

D 7,3

17

main()

{ int a=5;

while(!(a-->5))

{ switch(a)

{ case 1:a++;

case 4:a+=4;

case 5:a+=5;break;

default:a-=5;

}

}

printf("%d\n",a);

}

A 12

B7

C5

D 13

18 for

for(x=0,y=0;(y!=67)&&(x<5);x++) printf("----");

A

B

C 5

D 4

19 ABCdef

#include "stdio.h"

main()

{ char ch;

while((ch=getchar())!='\n')

{ if(ch>='A' && ch<='Z') ch=ch+32;

else if(ch>='a' && ch<='z') ch=ch-32;

printf("%c",ch);

}

printf("\n");

}

A ABCdef

B abcDEF

C abc

D DEF

20

int a=1;

do{ a=a*a; }while(!a);

A 1

B 2

C

D

3 33 1 abcde<> while
while((ch=getchar())=='e') printf("*");
2 while k=0; while(k=10) k=k+1;
3 main() { int x=0,y=5,z=3; while(z-->0 && ++x<5) y=y-1; printf("%d,%d,%d\n",x,y,z); }
4 1 10 main() { int a,b,c,i; a=c=0; for(i=0;i<=10;i+=2) { a+=i;

_ 1 ;

c+=b;

}

printf("=%d\n =%d\n",a, 2 );

}

5 100 3 6

main()

{ int i,j;

for(i=0; _ 1 ; i++)

{ j=i*10+6;

if(_ 2 )continue;

printf("%d\n",j);

}

}

6

main()

{ int s,i;

for(s=0,i=1;i<3;i++,s+=i);

printf("%d\n",s);

}

7 10

for(i=0;i<=;printf("%d \n",i+=2)) ;

8

2 1

1



1



1

6

22 33

nn



#include "math.h"

main()

{ int n=30000; double s=0.0; long i;

for(i=1;i<=n;i++) s=s+_ 1 ;

printf("pi=%f\n",_ 2 );

}

3 27

1 1 1 1 1

24

50

#include "stdio.h"

main()

{ int i=2; float sum=1;;

while( 1 )

{ sum=sum+1.0/i; 2 ; }

printf("sum=%f\n", 3 );

}

2



main()

{ float x,max,min;

scanf("%f",&x);

max=min= 1 ;

do{ if(x>max) max=x;

if(x<min) 2 ;

scanf("%f",&x);

} while( 3 );

printf("%f,%f",max,min);

}

3 3



main()

{ int n,i,j,k;

for(n=100; 1 )

/* 3 n */

{ i=n/100;

/* i n

*/

j= 2 ;

/* j n

*/

k=n%10;

/* k n

*/

if( 3 ) printf("%d\n",n);

}

}



2 40

1 a

A int a(10);

Bint n=10,a[n]; C int n;

D #define SIZE 10

scanf("%d",&n); int a[SIZE];

int a[n];

2 int a[10]; a

A a[10]

B a[3.5]

C a(5)

D a[10-10]

3 k

int k=3,s[2];

s[0]=k; k=s[1]*10;

A

B 33

C 30

D 10

4

main() { int i,k,a[10],p[3];

k=5; for(i=0;i<10;i++) a[i]=i;

for(i=0;i<3;i++) p[i]=a[i*(i+1)]; for(i=0;i<3;i++) k+=p[i]*2;

printf("%d\n",k); }

A 20

B 21

C 22

D 23

5 a

A int a[10]=(0,0,0,0,0);

B int a[10]=();

C int x=2,a[10]={10*x};

D int a[10]={0};

6 4

int a[12]={1,2,3,4,5,6,7,8,9,10,11,12};

char c='a',d,g;

A a[g-c]

B a[4]

C a['d'-'c']

D a['d'-c]

7

#define MAX 10

void main() { int i,sum,a[]={1,2,3,4,5,6,7,8,9,10};

sum=1; for(i=0;i<MAX;i++) sum-=a[i];

printf("sum=%d\n",sum); }

A sum=55

B sum=-54

C sum=-55

D sum=54

8

main()

{ int y=18,i=0,j,a[8];

do{ a[i]=y%2; i++; y=y/2; }while(y>=1);

for(j=i-1;j>0;j--) printf("%d",a[j]);

}

A 1000

B 1001

C 1010

D 1100

9 a

A int a[3][];

B float a(3,4); Cdouble a[1][4]; D float a(3)(4);

10 int a[3][4]; a

A a[2][2*1]

B a[1][3]

C a[4-2][0]

D a[0][4]

11 a

A int a[2][3]={0};

B int a[][3]={{1,2},{0}};

C int a[2][3]={{1,2},{3,4},{5,6}}; D int a[][3]={1,2,3,4,5,6};

12

A char a[][]={'a','b','c','d','e','f'};

B char a[2][3]='a','b';

C char a[][3]={'a','b','c','d','e','f'};

D char a[][]={{'a','b','c','d','e','f'}};

13

main()

{ int a[4][4],i,j,k; for(i=0;i<4;i++)

for(j=0;j<4;j++) a[i][j]=i-j; for(i=1;i<4;i++)

for(j=i+1;j<4;j++)

{ k=a[i][j]; a[i][j]=a[j][i]; a[j][i]=k; } for(i=0;i<4;i++) { printf("\n");
for(j=0;j<4;j++) printf("%4d",a[i][j]); }

}

A 0 -1 -2 -3

B 0123

1 0 -1 -2

-1 0 1 2

2 1 0 -1

-2 -1 0 1

3210

-3 -2 -1 0

C 0 -1 -2 -3

D 0123

1012

-1 0 -1 -2

2 -1 0 1

-2 1 0 -2

3 -2 -1 0

-3 2 1 0

14

main()

{ int i,a[4][4]={{1,3,5},{2,4,6},{3,5,7}};

printf("%d%d%d%d\n",a[0][3],a[1][2],a[2][1],a[3][0]);

}

A 0650

B 1470

C 5430

D

15

main()

{ int x[3][2]={0},i;

for(i=0;i<3;i++) scanf("%d",x[i]);

printf("%3d%3d%3d\n",x[0][0],x[0][1],x[1][0]);

}

2 4 6<>

A 200

B 204

C 240

D 246

16

A

B

C

D "="

17

char x[]="abcdef";

char x[]={'a','b' 'c','d','e','f'};

A x y

B x y

C x y

D x y

18

A char s1[10];s1="Ctest";

B char s2[]={'C','t','e','s','t'};

C char s3[20]="Ctest";

D char s4[30];strcpy(s4,"Ctest");

19 char s=[10];s="abcd";printf("%s\n",s);



A abcd

Ba

C abcd D

20 ABC

#include<stdio.h>

#include<string.h>

main()

{ char ss[10]="12345";

gets(ss); strcat(ss, "6789");

printf("%s\n",ss);

} A ABC6789

B ABC67

C 12345ABC6

D ABC45678

3 24 1 int int x[10]={0,2,4}; x 2 char a[]="\\141\141abc\t"; a 3 main() { int i,a[10]; for(i=9;i>=0;i--) a[i]=10-i; printf("%d%d%d\n",a[2],a[5],a[8]); } 4 main() { char ch[7]="65ab21"; int i,s=0; for(i=0;ch[i]>='0' && ch[i]<='9';i+=2) s=10*s+ch[i]-'0'; printf("%d\n",s); } 5 char s[100]d[100]int j=0i=0 s while(s[i]) { d[j]=; j++ ; } d[j]=0; 6 main() { char s[]="abcdef"; s[3]='\0'; printf("%s\n",s); } 7 main() { char ch[3][5]={"AAAA","BBB","CC"}; printf("\"%s\"\n",ch[1]); } 8 main() { char ch[]="abc",x[3][4]; int i; for(i=0;i<3;i++) strcpy(x[i],ch); for(i=0;i<3;i++) printf("%s",&x[i][i]); printf("\n"); }

3 36

1 #include "stdio.h" main() { int n=0,i; float x[1000],sum=0.0,ave,a; printf("Enter mark:\n"); scanf("%f",&a); while(a>=0.0 && n<1000) { sum+= 1 ; x[n]= 2 ; n++; scanf("%f",&a); } ave= 3 ; print("Output:\n"); printf("ave=%f\n",ave); for(i=0;i<n;i++) if( 4 ) printf("%f\n",x[i]); }
2 x x #define M 10 main() { int x[M][M]; int n,i,j; long s=1; printf("Enter a integer(<=10):\n"); scanf("%d",&n); printf("Enter %d data on each line for the array x\n",n); for( 1 ) for(j=0;j<n;j++) scanf("%d",&x[i][j]); for(i=0;i<n;i++) for( 2 ) 3 ; printf("%ld",s); }
3 a a main() { int a[ 1 ]={1,10,20,30,40,50,60,70,80,90},x,i,p; scanf("%d",&x); for(i=0,p=10;i<10;i++) if(x<a[i]) { p=i; 2 ; } for(i=9;i>=p;i--) a[i+1]=a[i]; 3 ; for(i=0;i<=10;i++) printf("%5d\n",a[i]); printf("\n"); }
4 t s s main()

{ static char s[30]="abcdefg",t[]="abcd"; int i=0,j=0;
while(s[i]!='\0') 1 ; while(t[j]!='\0') { s[i+j]=t[j]; j++; }
2 ; printf("%s\n",s); }



2 40

1

A double fun(int x,int y)

B double fun(int x,y)

{ z=x+y; return z; }

{ int z; return z; }

C fun (x,y)

D double fun(int x,int y)

{ int x,y; double z ;

{ double z;

z=x+y; return z; }

return z; }

2

A

B

C

D

3 return

A

B

C

D

4

A

B

C

D

5

A

B

C

D

6

A

B

C

D

7

double fun(int x, double y) { ...... }



A double fun(int x,double y)

B fun(int x,double y)

C double fun(int,double);

D fun(x,y);

8

A

B



C

D

9

A

B

C

D

10

A

B

C

D

11

A

B

C

D

12

int sum(int n)

{ int p=1,s=0,i;

for(i=1;i<=n;i++) s+=(p*=i);

return s;

}

main()

{ printf("sum(5)=%d\n",sum(5)); }

A sum(5)=151

B sum(5)=152

C sum(5)=153

D sum(5)=155

13

int c=1;

main()

{ static int a=5;int b=6;

printf("a=%d,b=%d,c=%d\n",a,b,c);

func();

printf("a=%d,b=%d,c=%d\n",a,b,c);

func();

}

func()

{ static int a=4;int b=10;

a+=2;c+=10;b+=c;

printf("a=%d,b=%d,c=%d\n",a,b,c);

}

A a=5,b=6,c=1

B a=5,b=6,c=11 C a=5,b=6,c=1

D a=5,b=6,c=1

a=6,b=21,c=11

a=5,b=21,c=11

a=5,b=21,c=11

a=6,b=21,c=11

a=5,b=6,c=11

a=5,b=6,c=11

a=5,b=6,c=11

a=5,b=6,c=11

a=8,b=31,c=21

a=8,b=31,c=21

a=8,b=31,c=21

a=5,b=31,c=21

14 ,

main()

{ int a=6,b=2,c;

c=f(a)/f(b);

printf("%d\n",c);

}

int f(int x)

{ int y;

y=x++*x++;

return y;

}

A9

B6

C 36

D 18

15

#include<stdio.h>

my()

{ static int x=3;

x++;

return(x);

}

main()

{ int i,x;

for(i=0;i<=2;i++) x=my();

printf("%d\n",x);

}

A3

B4

C5

D6

16

#include<stdio.h>

int abc(int u,int v)

{ int w;

while(v) { w=u%v; u=v; v=w; }

return u;

}

main()

{ int a=24,b=16,c;

c=abc(a,b);

printf("%d\n",c);

}

A8

B6

C5

D4

17

main()

{ static char s[]="abcdefgca";

p(s); printf("s[]=%s\n",s);

}

p(char s[])

{ int i,j;

for(i=j=0;s[i]!= '\0';i++) if(s[i]!='a'+2) s[j++]=s[i];

s[j]= '\0';

}

A s[]=abcdefgca B s[]=abdefga

C s[]=bcdefgc

D

18

void main()

{ int m=4,n=2,k;

k=fun(m,n); printf("%d\n",k);

k=fun(m,n); printf("%d\n",k);

}

int fun(int x,int y)

{ static int n=3,i=2;

i+=n+1; n=i+x+y;

return(n);

}

A 12

B 12

C 12

D 12

12

23

25

16

19

int x=1;

main()

{ int i=5;

fun(i);

printf("%d,%d\n",i,x);

}

fun(m)

int m;

{ m+=x;

x+=m;

{ char x='A'; printf("%d\n",x); }

printf("%d,%d\n",m,x);

}

A 65

BA

CA

D 65

6,1

6,1

6,7

6,7

6,1

6,1

6,7

5,7

20 ABC!

#include<stdio.h>

main()

{ void receiv();

receiv();

}

void receiv()

{ char c;

c=getchar();

putchar(c);

if(c!='!') receiv();

putchar(c);

}

A ABC!!

B ABC!ABC!

C ABC!!CBA

D ABCABC

3 30 1 fun((a,b),(c,d,e)); 2 3 C 4 C 5 #include <stdio.h> int x,y; one() { int a,b; a=25,b=10; x=a-b;y=a+b; } main() { int a,b; a=9,b=5; x=a+b;y=a-b; one(); printf("%d,%d\n",x,y): } 6 #include <stdio.h> main() { void printd() int n=123; printd(n); } void printd(int n) { int i; if(n<0) { n=-n; putchar('-'); } putchar(n%10+'0'); if((i=n/10)!=0) printd(i); } 7 xyz#, #include <stdio.h> main() { void recursion(); recursion(); } void recursion() { char c; c=getchar();

putchar(c);
if(c!='#') recursion();
putchar(c); } 8 #include<stdio.h> void fun(int x) { if(x/2>0) fun(x/2); printf("%d ",x); } main() { fun(3); printf("\n"); } 9 int a=1; int f(int c) { static int a=2;
c=c+1; return (a++)+c; } main() { int i,k=0; for(i=0;i<2;i++){ int a=3; k+=f(a); } k+=a; printf("%d\n",k); } 10 int k=0; void fun(int m) { m+=k; k+=m; printf("m=%d\n k=%d ",m,k++); } main() { int i=4; fun(i++); printf("i=%d k=%d\n",i,k); }
3 30 1 81 9 14412*1267626*26 main() { int n,k,a,b,c; for(k=1;;k++) { 1 if(n<100) 2 ; if(n>999) 3 ;

a=n/100; b= 4 ; c=n%10; if(flag(a,b,c)) printf("n=%d=%d*%d\n",n,k,k); } } flag 5 { return(!((x-y)*(x-z)*(y-z))); } 2 ex f1 f2 nmax e

ex 1 x x2 x3 xn xmax1

2! 3!

n! (max 1)2!

float f2(int n) { if(n= =1) return 1;
else return 6 ; } float f1(float x, int n) { int i; float j= 7 ;
for(i=1; 8 ;i++) j=j*x; return j; } #define nmax 20 main() { float x,exp=1.0; int n; printf("Input x value:"); scanf("%f",&x); for(n=1;n<nmax;n++) exp= 9 ; printf("x=%f,exp(x)=%f\n",x, 10 _); }


2 40 1 A "#" B C #define MAX D C 2 #define N 100 A N 100 B C 100 N C C 100 N

D 100

3

#define N 2

#define y(n) ((N+1)*n)

z=4*(N+y(5));

A

B z 68

C z 60

D z 180

4

#define F(X,Y) (X)*(Y)

main()

{ int a=3,b=4;

printf("%d\n",F(a++,b++));

}

A 12

B 15

C 16

D 20

5

#define f(x) (x*x)

main()

{ int i1,i2;

i1=f(8)/f(4); i2=f(4+4)/f(2+2);

printf("%d,%d\n",i1,i2); }

A 64,28

B 4,4

C 4,3

D 64,64

6 a int p

A int p=&a;

B int *p=a;

C int *p=*a;

D int *p=&a;

7

static int a[]={2,4,6,8}

static int *p[]={a,a+1,a+2a+3};

int **q;

q=p;

**(q+2)

A6

B2

C4

D8

8 int *px=&a;

A *px

Ba

C px

D &a

9 px

A px

B px

C px D px

10 int *px[10];

A px

B px

C A B C

D C

11 p y

A p=y

B *p=y[i]

C p=&y[i]

D p=&y

12 static int a[]={5,4,3,2,1},*p[]={a+3,a+2,a+1,a},**q=p; ,

*(p[0]+1)+**(q+2)

A5

B4

C6

D7

13 int *(*p)();

A p int

B p ,

C p ,

D p ,

14

char s[20]="Beijing",*p; p=s;

p=s;

A *p s[0]

B s p

C s p

D s p

15 int in s1s2 for(i=0;i<n;i++)

s2 n s1



A *s1++=*s2++;

B s1[n-1]=s2[n-1];

C *(s1+n-1)=*(s2+n-1);

D *(++s1)=*(++s2);

16

#include <stdio.h>

void main()

{ static char a[]="language",b[]="program"; char *ptr1=a,*ptr2=b;

int k;

for(k=0;k<7;k++)

if(*(ptr1+k)==*(ptr2+k)) printf("%c",*(ptr1+k)); }

A gae

B ga

C language

D

17

void fun1(char *p)

{ char *q;

q=p;

while(*q!='\0'){ (*q)++; q++; } }

main()

{ char a[]={"Program"},*p; p=&a[3]; fun1(p); printf("%s\n",a);
}

A Prohsbn

B Prphsbn

C Progsbn

D Program

18

void swap(char *x,char *y)

{ char t;

t=*x; *x=*y; *y=t;

}

main()

{ char *s1="abc",*s2="123"; swap(s1,s2); printf("%s,%s\n",s1,s2);
}

A 123,abc

B abc,123

C 1bc,a23

D 321,cba

19

main()

{ char *p[]={"3697","2584"}; int i,j; long num=0;

for(i=0;i<2;i++)

{ j=0;

while(p[i][j]!='\0') { if((p[i][j]-'0')%2) num=10*num+p[i][j]-'0';
j+=2;

}

}

printf("%d\n",num); }

A 35

B 37

C 39

20

void main()

{ char str[]="The_Microsoft"; int n=4; sub(str,0,n-1);

sub(str,0,strlen(str)-1);

printf("%s\n",str); }

sub(str,n1,n2)

char *str;

int n1,n2;

{ char c,*p;

p=str+n2;

str=str+n1;

while(str<p)

{ c=*str; *str=*p; *p=c;

str++; p--;

}

}

A tfosorciMThe_ B. ehT_Microsoft C tfosorciM_ehT

D 3975 D. Microsoft_The

3 30
1 x[1] main() { int x[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},*p[4],i; for(i=0; i<4; i++) { p[i]=&x[2*i+1]; printf("%d", p[i][0]); } printf("\n"); }
2 void swap(int *a, int *b) { int *t; t=a; a=b; b=t; } main()

{ int i=2,j=5,*p=&i,*q=&j; swap(p,q); printf("%d %d\n",*p,*q)
} 3
main() { int a[5]={2,4,6,8,10}, *p;
p=a; p++; printf("%d", *p); } 4 ____ #define M 5 #define N M+M main() { int k; k=N*N*5; printf("%d\n",k); } 5 :int a[4]={0,1,2,3},*p;p=&a[1];++(*p) 6 :int a[2][3]={2,4,6,8,10,12};*(&a[0][0]+2*2+1) *(a[1]+2) 7 : int *p[3],a[6],i; for(i=0;i<3;i++) p[i]=&a[2*i] ; *p[0] a *(p[1]+1) a
3 30 1 void fun(char str[10][81],char **sp) { int i; *sp = 1 ; for(i=1;i<10; i++) if(strlen(*sp)<strlen(str[i])) 2 ; } 2 "1234" 1234 int chnum(char *p) { int num=0,k,len,j; len=strlen(p); for( ; 3 ; p++) { k= 4 ; j=(--len); while( 5 ) k=k*10; num=num+k; } return (num); } 3 substr str int count(char *str, char *substr) { int i,j,k,num=0;

for(i=0; 6 ;i++) for( 7 ,k=0;substr[k]==str[j];k++,j++) if(substr [ 8 ]=='\0') { num++ ; break ; }
return (num); } 4 483 "384" void convert(char *a, int n) { int i;
if((i=n/10)!=0) convert( 9 ,i); else *(a+1)=0; *a= 10 ; }



18 5 918 6 100

1 age

struct student

{ int age; int sex; }stud1,*p;

A p->age

B student.age

C *p.age

D stud1.student.age

2

union data { int x; char y; float z; }a;

A data a

B a xyz

C a

D a

3

A

B

C

D

4

A

B

C

D

5 C

A C

B C

C

D

6 fopen



A "ab+"

B "wb+"

C "rb+"

D "ab"

7

struct s { int n; char *c; }*p;

char d[]={'a','b','c','d','e'};

struct s a[]={10,&d[0],20,&d[1],30,&d[2],40,&d[3],50,&d[4]};

#include <stdio.h>

main()

{ p=a;

printf("%d\n",++p->n);

printf("%d\n",(++p)->n);

printf("%c\n",++(*p->c));

}

A 11

B 11

C 10

D 10

20

20

20

20

c

b

c

b

8

struct student

{ char *name; int student_no; char grade; };

struct student temp,*p=&temp;

temp.name="chou";







A p->name

chou

B (*p)->name+2

h

C *p->name+2

e

D *(p->name+2)

o

9 ,

#include<stdio.h>

struct tree

{ int x; char *s; }t;

func(struct tree t)

{ t.x=10; t.s="computer"; return 0; }

main()

{ t.x=1; t.s="minicomputer";

func(t); printf("%d,%s\n",t.x,t.s);

}

A 10,computer

B 1,minicomputer C 1,computer

D 10,minicomputer

10

#include<stdio.h>

main()

{ union

{ int i[2];

long k;

char c[4];

}t,*s=&t;

s->i[0]=0x39;

s->i[1]=0x38;

printf("%lx ",s->k);

printf("%c\n",s->c[0]);

}

A 390038 39

B 380039 9

C 3938 38

D 3839 8

11 x x

union data { int i; char cha; double f; }x;

A7

B 11

C8

D 10

12

enum A {A0=1,A1=3,A2,A3,A4,A5};

enum A B;

B=A3; printf("%d\n",B);

A5

B3

C2

D

13 s num

struct student

{ int num;

int age;

}s,*p;

A s.num

B *p.num

C p->num

D (*p).num

14

A typedef integer int;

B typedef integer=int;

C typedef int integer;

D typedef int=integer;

15

#include <stdio.h>

struct sample

{ int a,b; char *ch; };

main()

{ struct sample arg;

arg.a=1000;arg.b=100;arg.ch="abcd";

f1(arg);

}

f1(struct sample param)

{ param.a+=param.b;

param.ch[2]='x';

printf("%d\n",param.a); printf("%s\n",param.ch); }

A 1000

B 1100

C 1100

D 100

abcd

abcd

abxd

abcd

16 fwrite

A fwrite(buffer,count,size,fp);

B fwrite(fp,size,count,buffer);

C fwrite(fp,count,size,buffer);

D fwrite(buffer,size,count,fp);

17 C fread(buffer,size,n,fp)

A fp n buffer

B fp n size buffer

C fp n size buffer

D fp n buffer

18

struct data

{ int i; char ch; float f; }b;

b

A7

B4

C1

D2






2 44

1-5 C B B B C

6-10

ABADC

11-15 C B C A A

16-22 A D A C A A D

1 2 3 56

1 x%2==0

11 12

2 a=2,b=3,c=4 3 -12
10 4 5 -14
6 3276732767
7 15
8 10A10
1012a 9 10,8,16
10,a 10 28

12 a=5 c=6 b=5 d=18
1A#B#C 13 2A# #B 14 5.169000
1scanf("%c",&ch); 15 2ch-=32;
3printf("%c\n",ch); 16 a=98,b=765.000000,c=4321.000000
123.12346 123.123457 17
00012345 abcdefgh
18 abc
19 a=3,b=5,x=35.000000,y=35.119999,c1=a,c2=b



2 40

1-5 B C A D A

6-10

CDBDC

11-15 C D C D D

16-20 C B D C A

3 30 1 9,10 2 000 i= 11 j= 15 3 k= 33 4 a=98,b=76.0,c=54 5 67,D

6 20 7 8,9 8 (x>=y)&&(y>=z) 9 **3 10 14

5 30 1 16.6 2 2#include<math.h> 3float s,p; 4&a,&b,&c 5a+b>c && b+c>a && c+a>b && a>0 && b>0 && c>0 6p=(a+b+c)/2.0;



2 40

1-5 D B A D B

6-10

BCABC

11-15 C C C D C

16-20 A A C B A

3 33 10

5 1i<10

2j%3

2 3 32-1 4 1b=i+1 2c-11

65 7 18 19 8 11.0/(i*i) 2sqrt(6*s)

3 27

1 1i<=50

2i=i+2

2 1x

2min=x

3 1n<=999;n++ 2n/10%10

3sum 3x>=0 3n==i*i*i+j*j*j+k*k*k



2 40

1-5 D D A B D

6-10

DBBCD

11-15 C C C A B

16-20 C C A D A

3 24 1 20

5 s[i++]

2 10

6 abc

3 852

7 "BBB"

46

8 abcbcc

3 36

1 1a

2a

3sum/n

4x[i]<ave

2 1i=0;i<n;i++

2j=i;j<n;j++ 3s=s*x[i][j]

3 111 11 2 break

3a[p]=x a[i+1]=x

4 1i++

2s[i+j]='\0'



2 40

1-5 D D A B A

6-10

DCCDA

11-15 D C A A D

16-20 A B C D C

3 30 12 2 3 4 5 1535

6 321 7 xyz##zyx 8 13 9 14
m=4 10 k=4 i=5 k=5

3 30

1 n=k*k;

6 n*f2(n-1)

2 continue

7 1

3 break

8 i<=n

4 n/10%10

9 exp+f1(x,n)/f2(n)

5 int x,int y,iny z

10exp



2 40

1-5 B B B A C

6-10

DACBB

11-15 D A D A A

16-20 B A C C A

3 30 1 2

5 2

1 2468

6 12

2 2 5

6 12

3 4

7 a0]

4 55

7 a[3]

3 30

1 str[0]

6 str[i]

2 *sp=str[i]

7 j=i

3 *p

8 k+1

4 *p-'0'

9 a+1

5 j--

10n%10+'0'



18 5 918 6 100

1-5 A D B D C

6-10 B A B B B

11-15 C A B C C

16-18 D B A

A



热文推荐
友情链接: 工作计划 总结汇报 团党工作范文 工作范文 表格模版 生活休闲