SISO 2011 级 C 语言复习指导

Click here to load reader

download SISO 2011 级 C 语言复习指导

of 60

description

SISO 2011 级 C 语言复习指导. 灰色部分不需要复习. 语法考试要求及考题解析 ( 2007 秋 ~2010 春). 1. C 语言基本概念 ⑴ 源程序格式、风格和结构。 main 函数特性。 C 程序保存 。 注释位置。 【 考题解析 】 [ 填空题 ] 在一个 C 语言源程序中, 必不可少的是 。 答案: main 函数定义 [ 单选题 ]. 以下叙述中正确的是 。 A. 在编译时可以发现注释中的拼写错误 B.C 语言程序的每一行只能写一条语句 C.main( ){ } 必须位于程序的开始 D.C 语言程序可以由一个或多个函数组成 - PowerPoint PPT Presentation

Transcript of SISO 2011 级 C 语言复习指导

  • *SISO 2011C

  • *

  • *

  • *2007~20101. C mainC []C main[]. ABCCmain( ){ }DC D

  • * [] main A B C DD[] A. mainB. mainC. CmainD. Cmain C

  • *[] A. CB. mainC. D. C[] A) C B) C) Cmain D) mainC

  • *[] ( ) A) CB) CC) CD) CC[] ( ) A)C B)CC)C D)CC

  • * , [] C3.14 double[]sizeof(int)210!f10!=3628800f Along int Bint Cshort int Dunsigned intA

  • *[] (22) A. \xff B.5L C. aEb D. 3.14U B[] printf("%d",0e); B. printf("%f",0e2); C. printf("%d",0x2); D. printf("%s","0x2"); A

  • *[] A_float Bswitch Csum D_123 B []C-3276832767 (3) 2 [] print B. FOR C. &a D. _00C[] C A printf Binclude Cfun DdefaultD[] printf(bye\bye101\101); (22) byye101A

  • *[] 1e-8/2+1.0f (3) int B. long C. float D. double D[] (2) int char=2; B. void a=0; C. int a=b=0; D. int a, b=a=0; D

  • * ++-- [] double x=3,c,*a=&x,*b=&c; Aa=b=0; Ba=&c,b=a; C&a=&b; D*b=*a;C

  • *[] char ss[8]=Red;sizeof(ss) A8 B4 C3 D1 : A [] #define d 2int x=5; float y=3.83; char c='d'; x++ B. y++ C. c++ D. d++ D[] C Asqrt(a)/2*b Bsqrt(a)/2/b Csqrt(a)/2b Dsqrt a/(2*b): B

  • *[] long x,y;xn4n10xy A. y=x/(10*(n-1)) B. y=x%(10*(n-1))C. y=x%(long)pow(10,n-1) D. y=x%(10(n-1))C[] double x=10,y=5;xy pow(x,y) pow(10,5)[] int x;sizeof(x)2x x+1>x 32767

  • *[] float y=3.14619;int x;x=y*100+0.5, y=x/100.0y 3.15 [] int a=3,b=4,c;c=1/2*(a+b);c A. 0 B. 3 C. 3.5 D. 4 A[] int a=5,b=2;b+=(float)(a+b)/2b 5[] char ch=g;ch= ch-a+A G ch-a 6A+6A6G

  • *[] int a=3,b=3,c=2;0 !a&&!b&&c B. !a||!b||c C. a==b&&b>=c D. a>=b&&b>c : A [] int a=3,b=4,c=5; 0 a&&b B. ay=2 .z>y>x. x>y==1.x==(x=0,y=1,z=2)A

  • *[] C sqrt(fabs(x))!=4*a/(b*c) sqrt(fabs(x))!=4*a/b/c [] int a=12,b=15,c;c=(a||(b-=a))bc A3.1 B15,12 C15,1 D3,12: C [] Cpow(x, )1.0/3[] int a=15,b=20,c=25,e;e=a>b? --c :++c;e 26

  • *[] A. s=(x>0)?1:(x
  • *[] int a=3, b=4; float x=4.5, y=3.5;(float)(a+b)/2+(int)x%(int)y : 4.5 3.5+4%3=4.5*[]int r=2;printf(%d,sizeof(2*3.14*r)); 8[] int n; float x,y;y=n=x=3.89;y 3 B. 3.0 C. 3.89 D. 4.0B x=3.89,n=3,y=3.0[] int a=3,b=4; A. a+b=7 B. a=|b| C. a=b=0 D. (a++)++ C[] int a=1,b=2; while(--a > 0&& --b>0)a=b;ab 0,2 B. 0,1 C. 1,1 D. 2,2A --b

  • * 2. printf(), scanf()getchar() , putchar() ,gets(),puts() [] int232768 printf("%d",32768); B. printf("%ld",32768); C. printf("%f",32768); D. printf("%c",32768);B

  • *[] sizeof(int)2 (10) 39999 A. printf("%u",39999); B. printf("%d",39999); C. printf("%ld",39999); D. printf("%lu",39999); B [] float f=123.45678;printf( %.3f,f ); . 1.23e+02 . 123.457 . 123.456780 . 1.234e+02 B

  • *@[] char s[80];s scanf("%s",s); B. scanf("%s",s[0]); C. s=gets(); D. s=getchar();A [] int a;scanf(a=%d,&a);a3 a=3 [] long a,b;ab scanf("%ld%ld,&a,&b"); B. scanf("%d%d",a,b);C. scanf("%d%d",&a,&b); D. scanf("%ld%ld",&a,&b);D

  • * : if-elseswitch[] Ce1e3s;for(e1; ;e3)s; A. e1;while(10)s;e3; B. e1;while(10){s;e3;}C. e1;while(10){e3;s;} D. while(10){e1;s;e3;}B [] int x,y;x0y1y-1 A. if(x>=0)y=1;else y=-1; B. y=x>=0?1:-1;C. switch() D. switch(x-abs(x)){ case x>=0: y=1; break; { case 0: y=1; break; default: y=-1; default: y=-1;} }C

  • *[] int a=1,b=2,c=0;if(a>b) c=a;a=b;b=c;ab (21) 2,0

  • *[] (1) (2) #include main( ){ int i,a=0,c=2; for(i=0;i
  • *[] (6) #include void main(){ int i,sum=0; for (i=0;i
  • * : whiledo-whileforgoto [] int i,k=1; unsigned j; .for(j=15;j>0;j-=2) k++; B. for(j=0;j
  • *[] #includevoid main(){ int a=1,b=1,i; for(i=1;i
  • *[] #include main(){ int s=1,n=235; do { s*=n%10; n/=10; }while(n); printf("%d\n",s);} 30

  • * : breakcontinuereturn [] #include #include main() { int x=8; for(;x>0;x--) { if(x%3) { printf("%d,", x--);continue;} printf("%d,", --x ); } } ( ) A) 7,4,2 B) 8,7,5,2 C) 9,7,6,4 D) 8,5,4,2,D

  • *3. [] Aint a[2]; Bint a[ ]={0,1}; Cint a[3]=0; Dint a[3][4]={0}; : C[] Aintnum[0..2008];B intnum[]; CintN=2008; D) #defineN 2008 intnum[N]; intnum[N]; D

  • *[] int p[10]={1,2},i=0;p[i]=p[i+1],i++; A. p[i]=p[i++]; B. p[++i]=p[i];C. p[++i]=p[i+1]; D. i++,p[i-1]=p[i];D [] int m[]={5,4,3,2,1},i=0;m m[--i] B)m[2*2] C)m[m[0]] D)m[m[i]]B

  • *[] char s1[10]=ABCDE,s2[10]=A\\0;printf(%d,strlen(strcpy(s1,s2))); 3[] #includemain(){int a[5]={1,2,3,4,5},b[5]={0,2,1,3,0},i,s=0;for(i=0;i
  • *[] char s[20]=Hello;sGood As="Good"; Bs[20]="Good"; Cstrcat(s,"Good"); Dstrcpy(s,"Good");D

  • *[] int a[4][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};12 A*(a+2)+3 B*(*(a+2)+3) C*(a[2]+3) Da[2][3]A

  • *[] 1 2 #include #define N 5 void main(){ static char a[N][N]; int i,j,t,start=0,end=N-1; char str[ ]="123",ch; for(t=0;t
  • * [] (1) (2) #include void main( ){ int i,j,a[3][3]; for(i=0;i
  • * [] typedef struct test{ int x,y[2]; }TEST; 27 Astruct test x; Bstruct x; Ctest x ; Dstruct TEST x;A

  • *[] stu1 typedef struct stu{char name[10];float score;}STU ; STU stu1; #define STU struct stu STU {char name[10];float score; }stu1; struct stu{char name[10];float score;}stu1; struct stu{char name[10];float score;}STU; STU stu1;D[] struct c{ double x,y}c1={1.2,1.3},c2={1.2,1.3},c3 struct d{ double x,y}d1={1.2,1.3},d2={1.2,1.3},d3, c3=0 B. c1==c2 C. c3=c1 D. d3=c1 C

  • *[] (1) (2) #include struct num{ int x,y ;} st[ ]={{1,10},{2,20},{3,30},{4,40},{-1,-1}},s1[2],s2[2];main(){ int i=0,j=0,k; for(k=0; st[k].x != -1; k++) { if(st[k].x%2) s1[i++]=st[k]; else s2[j++]=st[k]; } printf (" %d \n %d \n",s1[0].y ,s2[0].y );} (1) 10 (2) 20

  • *4. *[] char *p="%d,%d\n"; int a=1,b=2; printf(p,a,b); (4) 1,2[] doublex,y,*px,*py,px=&x,py=&y; Ascanf%f%f,x,y; Bscanf%f%f,&x,&y; Cscanf%lf%le,px,py; Dscanf%lf%lf,x,y;C

  • * [ ] #include main() { intm=1,n=2,*p=&m,*q=&n,*r; r=p; p=q; q=r; printf(%d,%d,%d,%d\n,m,n,*p,*q); } A)1,2,1,2 B)1,2,2,1 C)2,1,2,1 D)2,1,1,2B

  • *[] #include#includeint fun(int n){ int *p; p=(int *)malloc(sizeof(int)); *p=n; return *p;}main(){ int a; a=fun(10); printf(%d\n,a+fun(10)); }0 B) 10 C) 20 D) C

  • *(2) [] 2char *p=123;int c;c=sizeof(p);c A. 1 B. 2 C. 3 D. 4 : B[] double x[5]={1.0,2.0,3.0,4.0,5.0},*p=x;x*p B)x[5] C)*(p+1) D)*xB

  • *[] int x[10]={0,1,2,3,4,5,6,7,8,9},*p;4 Ap=x,*(p+4) Bp=x+4,*p++ Cp=x+3,*(p++) Dp=x+3,*++p: C[] char str[ ][10]={"Aoyun","Beijing"}, *p=&str[0][0]; printf("%s\n",p+10); printf ABeijing BAoyun Cing Dng : A

  • *[] int i,a[10],*p=a;110a[0]a[9] for(i=0;i
  • * [] int a[3][3]={0},*p1=a[1],(*p2)[3]=a;a[1][1]=1 A. *(p1+1)=1 B. p1[1][1]=1 C. *(*(p2+1)+1)=1 D. p2[1][1]=1B[] char s[10]=remind;puts(s+2); : mind[] char a[ ]="It is mine", *p="It is mine"; A. strcpy(a,yes)strcpy(p,yes) B. a=yesp=yes C. *a *p D. sizeof(a)sizeof(p) B

  • *[] #include main() {inta[10],*p,*s; for(p=a;p-a
  • *(3)

  • *[] struct student { char name[20]; int score; struct student *h; }stu,*p; int *q; Ap=&stu; Bq=&stu.score; Cscanf("%s%d",&stu); Dstu.h=p; : C

  • *[] 1 2 #include struct s{ int x,*y;}*p;int d[5]={10,20,30,40,50};struct s a[5]={100,&d[0],200,&d[1],300,&d[2],400,&d[3],500,&d[4]};void main( ){ p=a; printf("%5d",p->x++); printf("%5d\n",p->x); printf("%5d",*p->y); printf("%5d\n",*++p->y);} : (1) 100 101 (2) 10 20

  • *[] struct product{ char code[5]; float price;}y[4]={"100",100}; A. (*y).code[0]='2'; B. y[0].code[0]='2'; C. y->price=10; D. (*y)->price=10; D

  • * (4) [] #includemain(){ char *a[ ]={"abcd","ef","gh","ijk"}; int i; for(i=0;i
  • *[] #includemain(){ int a[]={1,2,3,4,5,6},*k[3],i=0; while(i
  • * 5. (2) [] 25 A. double fun(double x,double y){ } B. double fun(double x;double y){ }C. double fun(double x,double y);{ } D. double fun(double x,y){ } A

  • *[] fun A. int fun(int x,int y[ ]) B. int fun(int x,int y[x])C. int fun(int x,int y[3]) D. int fun(int x,int *y)B[] funvoid fun(int x, int y[])fun void fun(int x,int y[ ]); B. void fun(int x, int *y);void fun(int ,int); D. void fun(int ,int * );C[] long fun(int *x,int n,long *s);int a[4]={1,2,3,4}; long b,c; A. c=fun(a,4,b); B. c=fun(a[ ],4,&b);C. c=fun(a[4],4,b); D. c=fun(a,4,&b);D

  • *[] A. B. C. D. D [] func(f2(v1,v2),(v3,v4,v5),(v6,max(v7,v8))); func A)3 B)4 C)5 D)8A

  • *[] #include void func(int b){ int a; a=b; b=10; }void main(){ int a=10,b=20; func(b); printf("%d,%d",a,b);} : 10, 20

  • *[] #include void swap(int a,int b) { int t; if(a>b)t=a,a=b,b=t; } void main() { int x=13, y=11, z=12; if(x>y) swap(x,y); if(x>z) swap(x,z); if(y>z) swap(y,z); printf("%d\t%d\t%d\n", x,y,z); }8 13 11 12

  • *[] #includeint f(int x, int y){ return x+y; }void main(){ double a=5.5, b=2.5; printf("%d",f(a,b));} 7