41、下述程序的运行结果为( A )。
#include<stdio.h>
void abc(char*str)
{int a, b;
for(a=b=0;str{a}!=’’;a++)
if(str[a]!=’c’)
tr[b++]=str[a];
str[b]=’’;
}
void main ()
{
char str []=”abcdef”;
abc(str);
printf(“str[]=”%s”,str);
}
A)STR[]=abdef B)STR[]=abcdef C)STR[]=a D)STR[]=ab
42、下列各数组定义程序段,正确的是(C )。
A) int n=10;
int a[n];
B) main()
{char str[10]=”a man”}
C) static int[][3]={{0,1,2},{80,89,2}};
D) static char[5]=“i am a student.”;
43、以下main函数调用invert函数将串s的元素按逆序重新存放,(B )是不能正确实现此功能的程序。
void main()
{
char srt[]=“String”;
invert(s);
•••
}
A) void invert(char s[])
{
int t,I,j;
for(i=0,j=strlen(s)-1;i<j;i++,–j)
{
t=*(s+i);
*(s+i)=*(s+j);
*(s+j)=t;
}
}
B) void invert(char *s)
{
int t,i,j;
for(i=0,j=strlen(s);i<j;i++,–j)
{
t=s[i];
s[j]=s[i];
s[i]=t;
}
}
C) void invert(char *s)
{
int t,*h,*p;
h=s;
p=s+strlen(s)-1;
while(h<p)
t=*h,h=*p,*p=t,p–,h++;
}
D) void invert(char *s)
{
int t, *p;
p=s+stlen(s)-1;
while(s<p)
{
t=*s;
*s++=*p;
*p–=t;
}
}
44、下列程序的输出结果是( C )。
#include<stdio.h>
void fun();
void main()
{
int x=1;
if(x= =1)
{
int x=2;
printf(“%d”,++x);
}
void fun()
{
printf(“%d”,x++);
}
A)2,1,1 B)1,2,1 C)2,2,2 D)2,2,1
45、下面程序的输出是( A )。
#include<stdio.h>
#include<string.h>
main()
{
char *p1=“are”,*p2=“ARE”,a[50]=“xyz”;
strcpy(a+2,strcat(p1,p2));
printf(“%sn”,A);
}
A)xyareARE B)yzareARE C)zareARE D)xyzareARE
46、请选出以下程序段的输出结果( A )。
#include<stdio.h>
main()
{
char a1[10],a2[10],a3[10],a4[10];
scanf(“%s%s”,a1,a2);gets(a3);gets(a4);
puts(a1);puts(a2);puts(a3);puts(a4);
}
输入数据如下:(此处<CR>代表回车符)
mmmm nnnn<CR>
xxxx yyy<CR>
A) mmm
nnnn
xxxx xxx
B) mmmm
nnnn
xxxx
yyy
C) xxxx
nnnn
xxy yyy
zzzz
D) xxxxy yyy
xxxx
xxxx
yyy
47、以下程序的输出结果( B )。
#include<stdio.h>
#include<string.h>
main()
{
char a[100]={‘a’,’b’,’c’,’d’,’e’,’f’,’h’,’i’,’j’};
printf(“%dn”,strlen(str));
}
A)6 B)9 C)11 D)不能正常输出
48、以下程序的输出结果是( C )。
main()
{
char *a[][5]={“how”,”do”,”you”,”do”,”!”};
char **p;
int i;
p=a;
for(i=0;i<4;i++)
printf(“%s”,p[i]);
}
A)howdoyoudo! B)how C)howdoyoudo D)hdyd
49、下列程序段正确的是( D)。
A)#include<stdio.h>
main()
{
int i,j;
int(i)=j;
}
B)#include<stdio.h>;
mnain()
{
int i,j;
(int)i=j;
}
C)include<stdio.h>
main()
{
int i,j;
(int)i=j;
}
D)#include<stdio.h>
main()
{
int i,j;
(int)i=j;
}
50、下述程序的输出结果为( D )。
#include<stdio.h>
void main()
{
int a[5]={2,4,6,8,10};
int *p=a,**q=&p;
printf(“d%,”,*(p++));
printf(“%d”,**q);
}
A)4,4 B)2,2 C)4,5 D)2,4



