第1题:
有以下程序 #include <stdio.h> voidfun(char*t,char*s) {while(*t!=0) t++; while((*t++=*s++)!=0); } main() {char ss[10]="acc",aa[10]="bbxxyy"; fun(ss,aa); printf("%s,%s\n",ss,aa); } 程序的运行结果是
A.accxyy,bbxxyy
B.acc,bbxxyy
C.accxxyy,bbxxyy
D.accbbxxyy,bbxxyy
第2题:
下列程序的输出结果是______。# include<stdio.h>f(char 8s){ char *p=s; while(*p!='\0')p++; return(p-s);}main(){ printf("%d\n",f("ABCDEF"));}
A.3
B.6
C.8
D.0
第3题:
有以下程序 #include <stdio.h> int fun(char s[]) { int n=0; while(*s<='9'&&*s>='0') {n=10*n+*s-'0';s++;} return(n); } main() {char s[10]={'6','1','*','4','*','9','*','0','*'}; printf("%d\n",fun(s)); } 程序的运行结果是
A.9
B.61490
C.61
D.5
第4题:
请读程序: # include<stdio.h> f(char * s) {cahr * p=s; while(* p!='\0')p++; return(p-s); } main() {printf("%d\n”,f("ABCDEF"));} 上面程序的输出结果是 ( )
A.3
B.6
C.8
D.0
第5题:
有以下程序
#include<stdlo.h>
main( )
{char s[]={“012xy”};int i,n=0;
for(i=0;s[i]!=0;i++)
if(s[i]>=‘a’&&8[i]<‘z’)n++:
printf(”%d\n”,n);
}
程序运行后的输出结果是
A.0
B.2
C.3
D.5
第6题:
有以下程序
#include<stdio.h>
main()
{char s[]=“012xy\08s34f4w2”;
int i,n=0:
for(i=0;s[i]!=0;i++)
if(s[i]>=‘0’&&s[i]<=‘9’)n++:
printf(“%d\n”,n):
}
程序运行后的输出结果是
A.0
B.3
C.7
D.8
第7题:
有下列程序:
#include<stdi0.h>
voidfun(char*s)
{while(*s)
{if(*s%2==(1)printf("%C",*s);
s+十:
}
}
voidmain( )
{chara[]={"good");
fun(a);printf("n");
}
注意:字母a的ASCIl码值为97,程序运行后的输出结果是( )。
A.d
B.go
C.god
D.good
第8题:
有以下程序
#include <stdio.h>
void fun(char *t,char *s)
{ while(*t!=0) t++;
while((*t++=*s++)!=0);
}
main( )
{ char ss[10]="acc",aa[10]="bbxxyy";
fun(ss,aa); printf("%s,%s\n",ss,aa);
}
程序的运行结果是
A.accxyy,bbxxyy
B.acc,bbxxyy
C.accxxyy,bbxxyy
D.accbbxxyy,bbxxyy
第9题:
有以下程序
#include<stdio.h>
int fun(char s[])
{
int n=0;
while(*s<=’9’&&*s>=’0’) { n=10*n+*s-‘0’;s++; }
return(n);
}
main()
{
char s[10]={‘6’,’1’,’*’,’4’,’*’,’9’,’*’,’0’,’*’};
printf(“%d\n”,fun(s));
}
程序的运行结果是( )。
A.9
B.61490
C.61
D.5
第10题:
程序段char*s=”aBcD”;n=0;while(*s!=’/0’){if(*s>=’a’&&*s<=’z’)n++;s++;}执行后n=()。
第11题:
第12题:
61490
61
9
5
第13题:
有以下程序:
include<stdio.h>
main( )
{char s[]="012xy\O8s34f4w2‘;
int i;n=0; ,
for(i=0;s[i]!=0;i++)
if(s[i]>=0s[i]<=9)n++;
printf("%d\n",n);
}
程序运行后的输出结果是( )。
A.0
B.3
C.7
D.8
考查简单的C程序数组和循环。for循环是指i=0,如果s/[3]!=0,则i自动加1。if循环指的是s[i]中的元素大于等于0且小于等于9,则n加l,所以答案为B。
第14题:
有以下程序 #include <stdio.h> int fun(char s[]) { int n=O; while(*s<='9'&&*s>='0') { n=10*n+*s-'0'; s++; } return (n); } main() { char s[10]={ '6', '1', '*', '4', '*', '9', '*', '0', '*'}; printf("%d\n",fun(s)); }
A.9
B.61490
C.61
D.5
第15题:
有以下程序: #include<stdio.h> . main( ) {char s[]={"012xy"};int i,n=o; for(i=0;s[i]!=0;i++) if(s[i]>=as[i]<=z)n++; printf("%d\n",n); } 程序运行后的输出结果是( )。
A.0
B.2
C.3
D.5
第16题:
若已包括头文件<stdio.h>和<string.h>,运行下列程序段时输出结果是( )。 int i=0; char s1[10]="ABCD",s2[10]="EFG"; strcat(s1,S2); while(s2[i++]!='\0') s2[i]=s1[i]; puts(s2);
A.ABC
B.ABCDEF
C.EBCDEFG
D.CBD
第17题:
有以下程序 #include<stdio.h> int fun(char s[]) {int n=0; while(*s<=9&&*s>=0){n=10*n+*s-o;s++;) return(n); } main {char s[10]={6,1,*,4,*,9,*, 0,*); printf("%d",fun(s)); } 程序运行的结果是( )。
A.9
B.61490
C.61
D.5
第18题:
有以下程序 #include<stdio.h> void main() { char s[]={"01aXy"};int i,n=0; for(i=0;s[i]!=0;i++) if(s[i]<='a'&&s[i]>='z')n++; printf("%d\n",n); } 程序运行后的输出结果是( )。
A.0
B.2
C.3
D.5
第19题:
有以下程序
#include <stdio.h>
int fun(char s[ ])
{ int n=0;
while(*s<='9'&&*s>='0') {n=10*n+*s-'0';s++;}
retum(n);
}
main( )
{ char s[10]={'6','1','*','4','*','9','*','0','*'};
printf("%d\n",fun(s));
}
程序的运行结果是
A.9
B.61490
C.61
D.5
第20题:
有以下程序: #include <iostream> using namespace std; int main ( ) { char s1[10],s2[10]; char *p=s1,*q=s2; cin>>s1>>s2; while (*p ! =' \0 ' ) p++; while (*q!='\0') *p++=*q++; *p='\0'; cout<<s1<<end1; return 0; }
A.abcd0ghij
B.abcd0ghij0
C.abcd
D.abcdghij
第21题:
程序段intcount=0;char*s=”ABCD”;while(*s!=’/0’){s++;count++;}执行后count=()。
4
略
第22题:
0
3
7
8
第23题:
第24题:
0
2
3
5