2021知到答案 C语言程序设计2058334 最新智慧树满分章节测试答案

微信小程序
内容查看
查看价格5

第一章 单元测试

1、判断题:
构成c程序的基本单位是函数,有且只有一个主函数
选项:
A:对
B:错
答案: 【对】

2、判断题:
c语言一行可以写多条语句
选项:
A:错
B:对
答案: 【对】

第二章 单元测试

1、单选题:

以下选项中可用作C程序合法实数的是

选项:
A:9.12E
B:3.0e0.2
C:E9
D:0.1e0
答案: 【0.1e0】

2、单选题:

以下程序的输出结果是

#include <stdio.h>

main()

{   int x=10,y=10;printf(“%d %dn”,x–,–y);     }

选项:
A:9 10
B:10 10
C:10 9
D:9 9
答案: 【10 9】

3、单选题:
若有定义语句:int a=3,b=2,c=1;,以下选项中错误的赋值表达式是
选项:
A:a=(b=4)=3;
B:a=1+(b=c=4);
C:a=(b=4)+c;
D:a=b=c+1;
答案: 【a=(b=4)=3;】

4、单选题:

写出下面程序的运行结果:

#include <stdio.h>

void main( )

{

int x,y,z;

x=y=1;

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

printf(“%d,%d,%d “,x,y,z);

}

选项:
A:2,2,1
B:2,2,3
C:2,3,1
D:1,1,1
答案: 【2,3,1】

5、单选题:

写出下面程序的运行结果:

#include <stdio.h>

void main( )

{

int a=1,b=0;

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

printf(“%d”,a=2*b);

}

选项:
A:2,2
B:3,2
C:1,1
D:1,2
答案: 【1,2】

6、单选题:

写出下面程序的运行结果:

main()

{  int a,b,c=9;

a=3,b=4;

c%= a+b;

printf(“%d”,c)

}

选项:
A:3
B:2
C:1
D:4
答案: 【2】

7、单选题:

写出下面程序的运行结果:

#include <stdio.h>

main()

{ int a=4,b,c;

c=a+(b=2);

a+=a-=a*a;

printf(“%d,%d,%d “,a,b,c);

}

选项:
A:-12,2,6
B:4,2,6
C:-24,2,6
D:-8,2,6
答案: 【-24,2,6】

* 本部分为付费内容,您已获得阅读权限

第三章 单元测试

1、单选题:
有以下程序#include <stdio.h>void main(){char a,b,c,d;scanf(“%c%c“,&a,&b);c=getchar( );d=getchar( );printf(“%c%c%c%cn”,a,b,c,d);}当执行程序时,按下列方式输入数据12↙34↙则输出结果是

选项:
A:12 回车34
B:12 回车 3
C:12
D:1234
答案: 【12 回车 3】

2、单选题:
若有定义:int a,b;,通过语句scanf(“%d;%d”,&a,&b);,能把整数3赋给变量a,5赋给变量b的输入数据是
选项:
A:3 空格5
B:3分号5
C:35
D:3,5
答案: 【3分号5 】

3、单选题:

以下不能输出字符A的语句是(注:字符A的ASCIl码值为65,字符a的ASCIl码值为97)

选项:
A:printf(“%dn”,’A’);
B:printf(“%cn”,’B’-1);
C:printf(“%cn”,’a’-32);
D:printf(“%cn”,65);
答案: 【printf(“%dn”,’A’);】

4、单选题:
已知大写字母A的ASCII码是65,小写字母a的ASCII码是97,以下不能将变量c中的大写字母转换为小写字母的语句是
选项:
A:c=c+32;
B:c=(‘A’+c)%26-‘a’;
C:c=c-‘A’+’a’;
D:c=(c-‘A’)%26+’a’;
答案: 【c=(‘A’+c)%26-‘a’;】

5、单选题:
在C语言中,每个语句和数据定义是用______ 结束

选项:
A:逗号
B:括号
C:分号
D:句号
答案: 【分号】

第四章 单元测试

1、单选题:
以下程序段的输出结果是                 main(){     int   i=1,j=1,k=2;       if((j++||k++)&&i++) printf(“%d,%d,%dn”,i,j,k);}

选项:
A: 2,2,1
B:1,1,2
C:2,2,3
D:2,2,2       
答案: 【2,2,2       

2、单选题:
当c的值不为0时,能正确将c的值赋给变量a,b的是
选项:
A:(a=c)||(b=c)
B:a=c=b
C:(a=c)&&(b=c)
D:c=b=a
答案: 【(a=c)&&(b=c)

3、单选题:
以下程序的运行结果是      main(){  int  a=010, b=10;   printf(“%d,%dn” , ++a, b--);  }

选项:
A: 011, 9
B: 011, 10 
C:9, 10   
D:11, 10
答案: 【9, 10   

4、单选题:
已知int n,i=1,j=2;执行语句n=i<j?i++:j++;则i和j的值是
选项:
A:2,2
B:1,3
C:1,2
D:2,3
答案: 【2,2】

5、单选题:
#include <stdio.h> void main() { int x=1,y=0; if(!x) y++; else if(x==0)     if (x) y+=2;     else y+=3;  printf(“%dn”,y);  }  程序运行后的输出结果是

选项:
A:3
B:2
C:0
D:1
答案: 【0】

6、单选题:
#include <stdio.h>main(){int x=1,y=0,a=0,b=0;  switch(x)  {case 1:   switch(y)                 {case 0:a++;break;                  case1:b++;break;}  case 2:a++;b++;break;  case 3:a++;b++;break;  default:a++;b++;}printf(“na=%d,b=%d”,a,b);}A.a=1,b=0 B.a=2,b=1  C.a=1,b=1  D.a=2,b=2以上程序的输出是 

选项:
A:a=1,b=1
B:a=2,b=2
C:a=2,b=1
D:a=1,b=0
答案: 【a=2,b=1】

7、单选题:

下面程序的输出结果是:

#include<stdio.h>

void main()

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

if(a<b)

if(b<0)  c=0;

else  c+=1;

printf(“%d”, c);

}

选项:
A:1
B:4
C:2
D:3
答案: 【2】

8、单选题:

下程序功能是:将值为三位正整数的变量x中的数值按照个位、十位、百位的顺序拆分并输出,请填空。

#include<stdio.h>

void main()

{int x=256;

printf(“%d-%d-%d”,_______,x/10%10,x/100);}

选项:
A:x/100%10
B:x%10
C:x/10%10
D:x/10
答案: 【x%10】

9、单选题:

有以下程序

#include <stdio.h>

void main()

{ int x;

scanf(“%d”,&x);

if(x>15) printf(“%d”,x-5);

if(x>10) printf(“%d”,x);

if(x>5) printf(“%d “,x+5);

}

若程序运行时从键盘输入12<回车>,则输出结果为_________

选项:
A:17
B:7
C:12 17
D:12

答案: 【12 17】

10、单选题:

有以下程序(说明:字符0的ASCII码值为48)

#include <stdio.h>

main()

{char c1,c2;

scanf(“%d”,&c1);

c2=c1+9;

printf(“%c%c “,c1,c2);

}

若程序运行时从键盘输入48<回车>,则输出结果为_________

选项:
A:9
B:’0′ ‘9’
C:0
D:09
答案: 【09】

第五章 单元测试

1、单选题:
下述for循环语句________
int i,k;
for (i=0,k=-1;k=1;i++,k++)  printf(“***”);
选项:
A:只循环一次
B:一次也不循环
C:是无限循环
D:判断循环语句结束的条件非法
答案: 【是无限循环】

2、单选题:
#include <stdio.h>main( )
{ int x=0,y=5,z=3;
while(z–>0&&++x<5) y=y-1;
printf(“%d,%d,%dn”,x,y,z);
} 程序执行后的输出结果是
选项:
A:3,2,0
B:5,-2,-5
C:3,2,-1
D:4,3,-1
答案: 【3,2,-1】

3、单选题:
有以下程序
main( )
{ int i,s=0;
for(i=1;i<10;i+=2) s+=i+1;
printf(“%dn”,s);
} 程序执行后的输出结果是
选项:
A:自然数1~10的累加和
B:自然数1~9中的奇数之和
C:自然数1~10中的偶数之和
D:自然数1~9的累加和
答案: 【自然数1~10中的偶数之和】

4、单选题:
以下程序执行后的输出结果是()
main( )
{ int i,n=0;
for(i=2;i<5;i++)
{ do
{ if(i%3) continue;
n++;}
while(!i);
n++;}
printf(“n=%dn”,n);}
选项:
A:n=5
B:n=4
C:n=2
D:n=3
答案: 【n=4】

5、单选题:

程序运行后的输出结果是

#include<stdio.h>

main()

{ int i,j,m=2;

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

{for(j=3;j>0;j–)

{if(i+j>3) break;

m*=i*j;} }   printf(“m=%dn”,m);}

选项:
A:m=2
B:m=4
C:m=6
D:m=5
答案: 【m=2】

6、单选题:

以下程序运行后的输出结果是

#include<stdio.h>

main()

{int a=1,b=2;

for(;a<8;a++) { b+=a;a+=2;}

printf(“%d,%dn”,a,b);}

选项:
A:8,11
B:7,11
C:9,18
D:10,14
答案: 【10,14】

7、单选题:
以下程序运行后的输出结果是
main()
{   int c=0,k;
for(k=1;k<3;k++)
switch(k)
{ default:c+=k;
case 2:c++;break;
case 4:c+=2;break; }
printf(“%dn”,c);}
选项:
A:5
B:3
C:9
D:7
答案: 【3】

8、单选题:

以下程序的运行结果是
#include <stdio.h>
main()
{ int x=8;
for( ; x>0; x–)
{ if(x%3)   {printf(“%d,”,x–);                         continue;}
printf(“%d,”,–x); } }

选项:
A:9,7,6,4
B:8,5,4,2
C:8,7,5,2
D:7,4,2
答案: 【8,5,4,2】

9、单选题:

下述程序的输出结果

#include<stdio.h>

main()

{int y=10;

while(y–);  printf(“y=%d”,y);}

选项:
A:y=1
B:y=-1
C:y=0
D:y=随机值
答案: 【y=-1】

10、单选题:

下面的程序 的结果是:

main()

{ int x=3;

do

{printf(“%dn”,x-=2);}while(!(–x));}

选项:
A:输出的是1和-2
B:输出的是3和0
C:是死循环
D:输出的是1
答案: 【输出的是1和-2】

11、单选题:

下述for语句

int i,x;

for (i=0,x=1;i<=9&&x!=876;i++)  scanf(%d”,&x);

选项:
A:最多循环10次
B:一次也不循环
C:最多循环9次
D:无限循环
答案: 【最多循环10次】

12、单选题:

有以下程序

#include <stdio.h>

main()

{int s;

scanf(“%d”,&s);

while(s>0)

{ switch(s)

{ case 1:printf(“%d”,s+5);

case 2:printf(“%d”,s+4); break;

case 3:printf(“%d”,s+3);

default:printf(“%d”,s+1);break;

}

scanf(“%d”,&s);

}

}  运行时,若输入1 2 3 4 5 0<回车>,则输出结果是

选项:
A:

6566456

B:666656
C:66666
D:66656
答案: 【

6566456

第六章 单元测试

1、单选题:

若有以下说明:

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

char c=’a’,d,g; 则数值为4的表达式是

选项:
A:a[‘d’-‘c’]
B:a[‘d’-c]
C:a[4]
D:a[g-c]
答案: 【a[‘d’-c]】

2、单选题:

以下程序运行后的输出结果是

#include<stdio.h>

main()

{int a[5]={1,2,3,4,5},b[5]={0,2,1,3,0},i,s=0;

for(i=1;i<3;i++) s=s+a[b[i]]; printf(“%dn”,s);}

选项:
A:6
B:5
C:10
D:11
答案: 【5】

3、单选题:

#include<stdio.h>

main()

{int b[3][3]={0,1,2,0,1,2,0,1,2},i,j,t=1;

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

for(j=1;j<=1;j++) t+=b[i][b[j][i]];

printf(“%dn”,t);} 程序运行后的输出结果是

选项:
A:4
B:3
C:1
D:9
答案: 【4】

4、单选题:

若有以下定义和语句

char s1[10]=”abcd!”,s2[10]=”n123″;

printf(“%d,%d”,strlen(s1),strlen(s2));则输出结果是

选项:
A:5 8
B:10 5
C:5 5
D:10 7
答案: 【5 5】

5、单选题:

#include  <stdio.h>
main()
{  char s[]={“012xy”};        int i,n=0;
for(i=0;s[i]!=0;i++)
if(s[i]>’a’&&s[i]<=’z’) n++;
printf(“%dn”,n); }
程序运行后的输出结果是

选项:
A:5
B:2
C:3
D:0
答案: 【2】

6、单选题:
以下程序的运行结果是
#include <stdio.h>
main()
{ int s[12]={1,2,3,4,4,3,2,1,1,1,2,3},c[5]={0},i;
for(i=0;i<12;i++) c[s[i]]++;
for(i=1;i<5;i++) printf(“%d”,c[i]);
printf(“n”); }
选项:
A:1 2 3 4
B:2 3 4 4
C:1 1 2 3
D:4 3 3 2
答案: 【4 3 3 2 】

7、单选题:

有以下程序

#include <stdio.h>

main()

{ char s[]=”012xy8s34f4w2″;

int i,n=0;

for(i=0;s[i]!=0;i++)

if(s[i]>=’0’&&s[i]<=’9′) n++;

printf(“%dn”,n);

}  程序运行后的输出结果是

选项:
A:8
B:3
C:7
D:0
答案: 【3】

8、单选题:

#include<stdio.h>

main()

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

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

for(j=1;j<3;j++) printf(“%d”,a[i][j]);

printf(“ ”);}

程序运行后的输出结果是

选项:
A:1234
B:5689
C:5678
D:4567
答案: 【5689】

9、单选题:

#include<stdio.h>

main()

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

int b[3]={0},i;

for(i=1;i<3;i++) b[i]=a[i][2]+a[2][i];

for(i=1;i<3;i++)printf(“%d”,b[i]);

printf(“ ”);}

程序运行后的输出结果是

选项:
A:1418
B:14
C:1428
D:18
答案: 【1418】

10、单选题:

以下程序用以删除字符串中所有空格,横线处需要填哪条语句

#include<stdio.h>

main()

{char[100]={“Our teacher teach c language!”};

int i,j;

for(i=j=0;s[i]!=‘’;i++)

if(s[i]!=‘ ’) {s[j]=s[i];j++;}

s[j]=______;

printf(“%s ”,s); }

选项:
A:
B:” ”
C:48

D:’0′
答案: 【】

第七章 单元测试

1、单选题:

#include<stdio.h>

int fun()

{static int x=1;

x*=2;return x;}

main()

{int i,s=1;

for(i=1;i<=2;i++)  s=fun();

printf(“%dn”,s);}

程序运行后的输出结果是

选项:
A:8
B:4
C:1
D:0
答案: 【4】

2、单选题:

#include  <stdio.h>

int f(int t[],int n);

main()

{int a[4]={1,2,3,4},s;

s=f(a,4);

printf(“%dn”,s);

}

int f(int t[],int n)

{if (n>0)  return t[n-1]+f(t,n-1);

else return 0;} 程序运行后的输出结果是

选项:
A:4
B:6
C:10
D:14
答案: 【10】

3、单选题:

#include <stdio.h>
int f(int x)

{int y;

if(x==0||x==1) return (3);

y=x*x-f(x-2);

return y;

}

main()

{int z;

z=f(3); printf(“%dn”,z);} 程序的运行结果是

选项:
A:6
B:0
C:8
D:9
答案: 【6】

4、单选题:

#include <stdio.h>
int f(int n);
main()
{ int a=3,s;
s=f(a);s=s+f(a);printf(“%dn”,s);}
int f(int n)
{ static int a=1;
n+=a++;
return n; }
程序运行后的输出结果是

选项:
A:7
B:9
C:10
D:8
答案: 【9】

5、单选题:
#include  <stdio.h>
void fun(int p)
{  int d=2;
p=d++;
printf(“%d”,p); }
main()
{  int a=1;
fun(a);
printf(“%dn”,a); }
程序运行后的输出结果是
选项:
A:32
B:12
C:22
D:21
答案: 【21】

6、单选题:

#include<stdio.h>

int fun(int x,int y)

{ if(x==y)  return(x);

else  return((x+y)/2);

}

main()

{ int a=4,b=5,c=6;

printf(“%dn”,fun(2*a,fun(b,c))); }程序运行后的输出结果是

选项:
A:12
B:6
C:3
D:8
答案: 【6】

7、单选题:

#include <stdio.h>

int fun(int a,int b)

{ if(b==0) return a;

else return(fun(–a,–b));

}

main()

{ printf(“%dn”, fun(4,2));} 程序的运行结果是

选项:
A:1
B:4
C:2
D:3
答案: 【2】

8、单选题:

#include<stdio.h>

void fun(int a, int b)

{ int t;

t=a; a=b; b=t;}

main()

{ int c[10]={1,2,3,4,5,6,7,8,9,0}, i;

for(i=0; i<10; i+=2) fun(c[i], c[i+1]);

for(i=0; i<10; i++) printf(“%d,”, c[i]);

printf(“n”);}程序的运行结果是

选项:
A:2,l,4,3,6,5,8,7,0,9,
B:0,9,8,7,6,5,4,3,2,1,
C:l,2,3,4,5,6,7,8,9,0,
D:0,1,2,3,4,5,6,7,8,9,
答案: 【l,2,3,4,5,6,7,8,9,0,】

9、单选题:

#include <stdio.h>

void fun(int a[], int n)

{ int i, t;

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

{t=a[i]; a[i]=a[n-1-i]; a[n-1-i]=t;}

}

main()

{ int k[10]={1,2,3,4,5,6,7,8,9,10}, i;

fun(k,5);

for(i=2; i<8; i++) printf(“%d”, k[i]);

printf(“n”);} 程序的运行结果是

选项:
A:345678
B:876543
C:1098765
D:321678
答案: 【321678】

10、单选题:

有以下程序

void  swap1(int  c[])

{ int  t;

t=c[0];c[0]=c[1];c[1]=t;  }

void  swap2(int  c0,int  c1)

{int   t;

t=c0;c0=c1;c1=t;  }

main()

{int   a[2]={3,5},b[2]={3,5};

swap1(a);   swap2(b[0],b[1]);

printf(“%d %d %d %dn”,a[0],a[1],b[0],b[1]); }

执行后输出的结果是:

选项:
A:5  3  5  3
B:3  5  3   5
C:5  3  3   5
D:3  5  5   3
答案: 【5  3  3   5】

11、单选题:

有以下程序

#include <stdio.h>

int fun()

{ static int x=1;

x*=2;

return x;

}

main()

{ int i,s=1;

for(i=1;i<=3;i++)  s*=fun();

printf(“%dn”,s);

}

程序运行后的输出结果是

选项:
A:0
B:10
C:64
D:30
答案: 【64】

第八章 单元测试

1、单选题:
下列语句组中,正确的是
选项:
A:char  s[7];s={”Olympic”};
B:char  s[7]; s=”Olympic”;
C:char  *s;s= ” Olympic “;
D:char  *s;s={”Olympic”};
答案: 【char  *s;s= ” Olympic “;

2、单选题:

 void fun(char *c,int d)

 { *c=*c+1; d=d+1;

   printf(“%c,%c,”,*c,d);

 }

main()

{ char b=‘a’,a=‘A’;

  fun(&b,a);  printf(“%c,%cn”b,a); 

}程序运行后的输出结果是

选项:
A:b,B,B,A
B:a,B,a,B
C:a,B,B,a 
D:b,B,b,A
答案: 【b,B,b,A

3、单选题:
设有定义double  a[10],*s=a;以下能够代表数组元索a[3]的是
选项:
A:(*s)[3] 
B:*s[3]    
C:*(s+3) 
D:*s+3
答案: 【*(s+3) 

4、单选题:

#include<stdio.h>

#define N 8

void fun(int *x,int i)

{

 *x=*x+i;

}

main()

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

 fun(a,2); 

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

{ printf(“%d”,a[i]);}

  printf(“n”);

程序运行后的输山结果是

选项:
A:3234
B:2234
C:1234
D:1313
答案: 【3234】

5、单选题:
#include <stdio.h>
main()
{ int m=1,n=2,*p=&m,*q=&n,*r;
r=p;p=q;q=r;
printf(“%d,%d,%d,%dn”,m,n,*p,*q);
}
程序运行后的输出结果是

选项:
A:1,2,1,2
B:2,1,2,1
C:1,2,2,1
D:2,1,1,2
答案: 【1,2,2,1

6、单选题:

#include <stdio.h> 
#include <string.h>
main()
{char 
str[][20]={“One*World”,”One*Dream!”};  char *p=str[1];
printf(“%d,”,strlen(p));
printf(“%sn”,p);  }
程序运行后的输出结果是

选项:
A:9,One*Dream!
B:9,One*World 
C:10,One*Dream! 
D:10,One*Wor        
答案: 【10,One*Dream! 

7、单选题:
下列函数的功能是
fun(char  *a,char  *b)
{ while((*b=*a)!=”){a++;b++;}
}
选项:
A:将a所指字符串和b所指字符串进行比较 
B:检查a和b所指字符串中是否有” 
C:使指针b指向a所指字符串
D:将a所指字符串赋给b所指空间 
答案: 【将a所指字符串赋给b所指空间 

8、单选题:

#include<stdio.h>
main
()

{char  *s=“ABC”;
do
{printf
“%d”,*s%10;s++;} while(*s);   }字母A的ASCII码值为65.程序的输出结果是
选项:
A:5670
B:567
C:ABC
D:656667
答案: 【567

9、单选题:

#include<stdio.h>

void fun(char  *s)

{ while(*s)

 { if(*s%2==0) printf(“%c”,*s);s++; }

}

main()

{ char  a[]={“abcd”};  fun(a);printf(“n”);}
字母a的ASCⅡ码值为97,程序的输出结果是

选项:
A:ab
B:abcd
C:cd
D:bd
答案: 【bd】

10、单选题:
#include <stdio.h>
void  f(int *p,int *q);
main()
{ int m=1,n=2,*r=&m;
f(r,&n); printf(“%d,%d”,m,n); 
}
void  f(int *p,int *q)
{p=p+1;*q=*q+1;}
程序运行后输出的结果是

选项:
A:1,3 
B:1,2
C:2,3
D:1,4
答案: 【1,3 

11、单选题:

#include <stdio.h>

main()

{ char *a[ ]={“abcd”,”ef”,”gh”,”ijk”};

  int i;

  for(i=0;i<4;i++)         printf(“%c”,*a[i]);  }
程序运行后输出的结果是

选项:
A:abcd
B:aegi 
C:dfhk
D:abcdefghijk
答案: 【aegi 

12、单选题:

#include <stdio.h>

int b=2;

int fun(int *k)

 b=*k+b;return(b);

}

main()

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

  for(i=2;i<4;i++) {b=fun(a)+b;printf(“%3d”,b);}  

}程序运行后输出的结果是

选项:
A:10 16
B:8  10
C:10  12
D:6  14
答案: 【6  14

13、单选题:

以下程序的输出结果是________
#include<stdio.h>
void swap(int *a,int *b)
{ int *t;
{ t=a; a=b; b=t; }

}

main()
{ int i=3,j=5,*p=&i,*q=&j;
swap(p,q); printf(“%d %d ”,*p,*q);
}

选项:
A:3 5 53
B:5 3
C:3 5
答案: 【3 5】

14、单选题:
以下程序的输出结果是__________
#include<stdio.h>
main()
{ int a[5]={2,4,6,8,10}, *p;
p=a; p++;
printf(“%d”,*p);
}
选项:
A:4
B:5
C:6
D:2
答案: 【4】

15、单选题:
有以下程序
void f( int y,int *x)
{y=y+*x; *x=*x+y;}
main( )
{ int x=2,y=4;
f(y,&x);
printf(“%d %d ”,x,y);
} 执行后输出的结果是
选项:
A:8 4
B:4 2
C:2 4
D:4 8
答案: 【8 4】

16、单选题:

以下sstrcpy( )函数实现字符串复制,即将t所指字符串复制到s所指向内存空间中,形成一个新的字符串s。请填空。
void sstrcpy(char *s,char *t)
{

while(*s++=______);

}
main( )
{ char str1[100],str2[]=”abcdefgh”;
sstrcpy(str1,str2);
printf(“%s ”,str1);
}

选项:
A:*t
B:*s
C:*s++
D:*t++
答案: 【*t++】

第九章 单元测试

1、单选题:

#include<stdio.h>

#include<string.h>

struct A

{int a;

char b[10];

double c;};

void f(struct A t);

main()

{struct A a={1001,”ZhangDa”,1098.0};

f(a);

printf(“%d,%s,%6.1fn”,a.a,a.b,a.c);

}

void f(struct A t)

{t.a=1002; strcpy(t.b,”ChangRong”); t.c=1202.0; }结果是

选项:
A:1001,changRong,1098.0
B:1002,chang Rong,1202.0
C:1001,zhangDa,1098.0
D:1002,Zhang Da,1202.0
答案: 【1001,zhangDa,1098.0】

2、单选题:

#include <stdio.h>
struct ord
{ int x,y;} dt[2]={1,2,3,4};

main( )
{ struct ord *p=dt;
printf(“%d,”,++p->x);   printf(“%dn”,++p->y); }
程序的运行结果是

选项:
A:4,1
B:2,3
C:1,2
D:3,4
答案: 【2,3】

3、单选题:

#include <stdio.h>

struct st

{ int x, y;} data[2]={l,10,2,20};

main()

{ struct st *p=data;

printf(“%d,”, p->y);

printf(“%dn”,(++p)->x);}  程序的运行结果是

选项:
A:20,1
B:10,2
C:20,2
D:10,1
答案: 【10,2  】

4、单选题:

#include <stdio.h>

main()

{ struct STU

{ char name[9];

char sex;

double  score[2];

};

struct STU a={“Zhao”,’m’,85.0,90.0),b={“Qian”,’f’,95.0,92.0);

b=a;

printf(“%s,%c,%2.0f,%2.0fn”, b.name,b.sex,b.score[0],b.score[1]);

}程序的运行结果是

选项:
A:Zhao,m,85,90
B:Qian,f,95,92
C:Zhao,f,95,92
D:Qian,m,85,90
答案: 【Zhao,m,85,90】

5、单选题:

有以下程序

struct S

{ int a,b;} data[2]={10,100,20,200};

main()

{ struct S p=data[1];

printf(“%dn”,++(p.a));

} 程序运行后的输出结果是

选项:
A:20
B:10
C:21
D:11
答案: 【21】

6、单选题:

#include <stdio.h>
typedef struct
{int num;double s;} REC;

void fun1(REC x)

{x.num=23;x.s=88.5;}

main()
{ REC a={16,90.0};
fun1(a);
printf(“%d “,a.num); }

上述程序的输出结果为 ________

选项:
A:23
B:90
C:16
答案: 【16】

7、单选题:

下程序运行结果________

#include <stdio.h>
#include <string.h>
struct  A

{int a;

char b[10];

double c;

};
void  f (struct A *t);

main()
{struct A a={1001,”ZhangDa”,1098.0};
f(&a);

printf(“%d,%s,%6.1f ”,a.a,a.b,a.c);

}
void f(struct A *t)
{

strcpy(t->b, ”ChangRong”);

}

选项:
A:1001,ZhangDa,1098.0
B:1001,ChangRong,1098.0
C:1001,”ZhangDa”,1098.0
D:1001,”ChangRong”,1098.0
答案: 【1001,ChangRong,1098.0】

8、单选题:

以下程序运行后的输出结果是 ________
struct NODE
{ int  num;

struct NODE  *next; }
main()
{ struct NODE s[3],  *p, *q, *r;

int  sum=0;

s[0].num=1; s[1].num=2; s[2].num=3;
s[0].next=s+1; s[1].next=s+2; s[2].next=s;
p=s; q=p->next; r=q->next;
sum+=q->next->num;

sum+=r->next->next->num;
printf(“%d “, sum);

}

选项:
A:1
B:5
C:2
D:4
答案: 【5】

9、单选题:

函数fun的功能是统计person所指结构体数组中所有性别(sex)为M的记录的个数存入n中,请填空:

#define  N  3

typedef  struct

{int num;

char nam[10];

char sex;}  SS;

int  fun(SS person[])

{int i,n=0;

for(i=0;i<N;i++)  if(______==’M’ )   n++;

return n;

}

main()

{SS  W[N]={{1,”AA”,’F’},{2,”BB”,’M’},  {3,”CC”,’M’}};

int n;

n=fun(W);

printf(“n=%d ”,n); }

选项:
A:person[i].sex
B:person[i]
C:person[i].name
答案: 【person[i].sex】

10、单选题:

以下程序运行后的输出结果是________

#include  <stdio.h>

main()

{ char *p; int i;

p=(char *)malloc(sizeof(char)*20);

strcpy(p,”welcome”);

for(i=6;i>=0;i–) putchar(*(p+i));

printf(” -“); free(p);

}

选项:
A:elcome
B:emocle
C:welcome
D:emoclew
答案: 【emoclew】

点点赞赏,手留余香 给TA打赏

AI创作

评论0

请先

2021知到答案 创业思维与创业管理 最新智慧树满分章节测试答案
2021知到答案 创业思维与创业管理 最新智慧树满分章节测试答案
刚刚 有人购买 去瞅瞅看
2022知到答案 人文与医学 最新智慧树满分章节测试答案
2022知到答案 人文与医学 最新智慧树满分章节测试答案
3分钟前 有人购买 去瞅瞅看
2022知到答案 唐宋名家词 最新智慧树满分章节测试答案
2022知到答案 唐宋名家词 最新智慧树满分章节测试答案
8分钟前 有人购买 去瞅瞅看
支持多种货币
支持多种货币付款,满足您的付款需求
7天无忧退换
安心无忧购物,售后有保障
专业客服服务
百名资深客服7*24h在线服务
发货超时赔付
交易成功极速发货,专业水准保证时效性

站点公告

课程作业辅导,有需要加下方微信

显示验证码

社交账号快速登录