下面函数的功能是 。 strlen1(char *s ) { char *p=s; while(*p!=‘0’) p++; return p-s; }
A.字符串反向
B.字符串比较
C.字符串连接
D.字符串求长度
第1题:
下列程序的输出结果是______。# 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
第2题:
以下程序运行后的输出结果是( )。
include
char*ss(char*s)
{char*p,t;
P=s+1;t=*s;
while(*p){ *(P-1)=*P;P++;}
*(P-1)=t;
return s;
}
main()
{char*p,str[10]="abcdefgh";
p=ss(str);
printf("%s\n",p);
}
第3题:
下面程序的运行结果是 #include<stdio.h> main() {int a=28,b; char s[10],*p; p=s; do{b=a%16; if(b<10) *p=b+48; else*p=b+55; p++;a=a/5;}while(a>0); *p='\0';puts(s);}
A.10
B.C2
C.C51
D.\0
第4题:
函数mycmp(char *s,char *t)的功能是比较字符串s和t的大小,当s等于t时返回0,当s>t时返回正值,当s<t时返回负值,请填空。mycmp( char *s,char *t){ while (*s==*t) { if (*s==’\0’)return 0; ++s;++t; } return();}
第5题:
以下程序运行后,输出结果是______。#include<stdio.h>ss (char *s){ char *p=s; while(*.p)p++; return(p-s);}main(){ char *a="abded"; int i; i=ss((A); print ("%d\n",i);}
A.8
B.7
C.6
D.5
第6题:
有如下的程序: int f(char*s) { char *p=s; while(*p!='\0') p++; return(p-s); }如果在主程序中用下述语句调用上述函数,则输出结果为______。 printf("%d\n",f("best one!"));
A.3
B.6
C.8
D.9
第7题:
设有如下函数定义。若在主函数中用语句cout<<f("good")调用上述函数,则输出结果为(48)。 int f(char *s){ char *p=s; while(*p! ='\0')p++; return(p-s); }
A.3
B.4
C.5
D.6
第8题:
以下程序的输出结果是______。 char cchar(char ch) { if(ch>='A'&&ch<='z')ch=ch-'A'+'a'; return ch; } main() { char s[]="ABC+abc=defDEF",*p=s; while(* p) { * p=cchar(* p); p++; } printf("% s\n", s); }
A.abe+ABC=DEFdef
B.abc+abe=defdef
C.abcaABCDEFdef
D.abcabcdefdef
第9题:
以下程序运行后,输出结果是( ) #include<stdio.h> ss(char *s) { char*p=s; while(*p) p++ return(p-s); } main() { char *a="abded" int i; i=ss(a) ; printf("%d\n",i); }
A.8
B.7
C.6
D.5
第10题:
有以下程序: #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
第11题:
若有如下程序: void a(char*p,char c) {while(*p) { if(*p==c)*p=c-'b'+'B';; p++; } } main() {char s[50]="abcdeeffgee",b='e'; a(s,b);printf("%s\n",s); } 则程序运行后的输出结果是( )。
A.Abcdeeffgee
B.ABCDeeFFGee
C.abcdEEffgEE
D.ABCDEEFFGEE
第12题:
串的操作函数str定义为: int str(char*s){ char*p=s; while(*p!=’\0')p++; return p=s; } 则str("abcde")的返回值是 ( )
A.3
B.4
C.5
D.6
第13题:
以下程序的输出结果是( )。 #include <stdio.h> charcchar(char eh) { if(ch>='A,&&ch<='Z') ch=ch-'A'+'a'; return ch; } main() { char s[]="ABC+abc=defDEF",*p=s; while(*p) { *p=cchsr(*p); p++; } printf("%s\n",s); }
A.abc+ABC=DEFdef
B.abc+abc=defdef
C.abcABCDEFdef
D.abcabcdefdef
第14题:
下面程序的运行结果是【 】。
include<iostream.h>
void main()
{
char s[]="9876",*p;
for(p=s;p<s+2;p++)
cout<<p;
}
第15题:
下面程序的输出是______。 char s[]="ABCD"; main() { char *p; for(p=s;p<s+4;p++) printf("%s\n",p); }
A.ABCD BCD CD D
B.A B C D
C.D C B A
D.ABCD ABC AB A
第16题:
下列程序的执行结果是______。 in(f(char*s) { char*p=s; while(*p!='\0')p++; return(p-s); } main() { printf("%d\n",f("goodbye!")); }
A.3
B.6
C.8
D.0
第17题:
设有如下函数定义,则输出结果为______。 char*fun (char*str) {char*p=str; while(*p) { if(*p>'d') continue; p++; } return p; } main() { printf("%s\n",fun("welcome!")); }
A.welcome!
B.come!
C.w
D.程序陷入死循环中
第18题:
请读程序: # 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
第19题:
若有如下程序: f2(char*t) { *t=*t-32; return(*t); } fl(char*p) { for(;*p!='\0';p++) if(*p>='a'&&*p<='z')f2(p); } main() {char a[10]="abcbgH"; f1(a); printf("%S",a); } 则程序运行后的输出结果是( )。
A.ABCBGH
B.abcdefgh
C.abcdg
D.EFH
第20题:
以下程序的输出结果是【 】。
char s[ ]="XYZQ";
void main(){
char *p;
for(p = s; p < s+4; p++)
cout<<p<<end1;
}
第21题:
以下程序运行后的输出结果是______。 ss(char*s) { char*p=s; while(*p)p++; return(p-s); } main() { char*a="abded";int i; i=ss(a); printf("%d\n",i); }
A.8
B.7
C.6
D.5
第22题:
设有如下函数定义,则输出结果为_______。 char*fun(char*str) { char*p=str; while(*p) {if(*p>'d')continue; p++; } return p; } main() { printf("%s\n",fun("welcome!")); }
A.welcome
B.come!
C.w
D.程序进入死循环
第23题:
以下程序的输出结果是 char cchar(char ch) { if(ch>='A'&&ch<='Z') ch=ch-'A'+'a'; return ch; } main ( ) { char s [] = "ABC+abc=defDEF" , *p=s; while (*p) { *p=cchar(*p); p++; } printf { "%$\n", s); }
A.abc+ABC=DEFdef
B.abc+abc=defdef
C.abcABCDEFdef
D.abcabcdefdef
第24题:
6
5
4
3