A、将p1所指字符串复制到p2所指内存空间中
B、将p1 所指字符串的地址赋给指针 p2
C、对p1和p2两个指针所指字符串进行比较
D、检查p1和p2两个指针所指字符串中是否有‘\0’
第1题:
下列程序的运行结果是【 】。
include<iostream. h>
include<string. h>
void main()
{
char * a[5]={"stuent","worker","teacher","soldier"," peasant"};
char * p1, * p2;
p1=p2=a[0]
for(int i=0;i<5;i++)
{
if(strcmp(a[i],p1)>0)
p1=a[i];
if(strcmp(a[i],p2)<0)
p2=a[i];
}
cout<<p1<<","<<p2<<endl;
}
第2题:
有以下程序
void fun(char *a, char *b)
{ a=b; (*a)++; }
main()
{ char c1='A',c2='a',*p1,*p2;
p1=&c1; p2=&c2; fun(p1,p2);
printf("%c%c\n",c1,c2);
}
程序运行后的输出结果是
A.Ab
B.aa
C.Aa
D.Bb
第3题:
以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz", strcpy(str+2,strcat(p1,p2)); printf("%s\n",str); } 的输出是______。
A.xyzabcABC
B.zabcABC
C.yzabcABC
D.xyabcABC
第4题:
下面程序的输出结果是
#include<iostream.h>
#include<string.h>
void main( )
{
char p1[10] ,p2[10] ;
strcpy(p1,"abc") ;
strcpy(p2,"ABC") ;
char str[50] ="xyz";
strcpy(str+2,strcat(p1,p2) ) ;
cout < < str;
}
A.xyzabcABC
B.zabcABC
C.xyabcABC
D.yzabcABC
第5题:
下面程序的输出结果是 #include<iostream.h> #include<string.h> void main( ) { char p1[10],p2[10] strcpy(p1,"abc"); strcpy(p2,"ABC"); char str[50]="xyz"; strcpy(str+2,strcat(p1,p2));
A.xyzabcABC
B.zabcABC
C.xyabcABC
D.yzabcABC
第6题:
下面程序的输出结果为______。 #include<string.h> main() { char p1[7]="abc",p2[]="ABC",str[50]="xyz"; strcpy(str,strcat(p1,p2)); printf("%s",str); }
A.xyzabcABC
B.abcABC
C.xyzabc
D.xyzABC
第7题:
下面程序的输出是______。 fun(char *s,int p1,int p2) { char c; while(p1<p2) { c=s[p1];s[p1]=s[p2];s[p2]=c;p1++;p2--;} } main() { char a[]="ABCDEFG",k,*p; fun(a,0,2);fun(a,4,6); printf("%s\n ",a); }
A.ABCDEFG
B.DEFGABC
C.GFEDCBA
D.CBADGFE
第8题:
下面程序的输出结果是( )。 #include<iostream.h> #include<string.h> void main() { char p1[10],p2[10]; strcpy(p1,”abc”); strcpy(p2,”ABC”); charsty[50]=“xyz”; strcpy(str+2,strcat(p1,p2)); cout<<str; }
A.xyzabcABC
B.zabcABC
C.xyabcABC
D.yzabcABC
第9题:
有以下程序
#include<stdio.h>
#include<string.h>
void fun(char *w,int m)
{ char s,*p1,*p2;
p1=w;p2=w+m-1;
while(p1<p2){s=*p1;*p1=*p2;*p2=s;p1++;p2--;}
}
main()
{ char a[]="123456";
fun(a,strlen(a));puts(a);
}
程序运行后的输出结果是
A.654321
B.116611
C.161616
D.123456
第10题:
有以下程序: #include <stdio.h> void fun(char *a, char *b) { a=b; (*a)++;} main() { char c1='A',c2='a',*p1,*p2; p1=&c1; P2=&c2; fun(p1,p2); printf("%c%c\n",c1,c2); } 程序运行后的输出结果是( )。
A.Ab
B.aa
C.Aa
D.Bb
第11题:
以下与库函数strcpy(char*p1,char*p2)功能不相等的程序段是()
第12题:
to Beijing!
you to Beijing!
Welcome you to Beijing!
Beijing!
第13题:
请补充函数fun(),该函数的功能是判断一个数是否为回文数。当字符串是回文时,函数返回字符申:yes!,否则函数返回字符串:no!,并在主函数中输出。所谓回文即正向与反向的拼写都一样,例如:abcba。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<string.h>
include<stdio.h>
char *fun(char*str)
{
char *p1,*p2;
int i, t=0;
p1=str;p2=str+strlen(str)-1;
for (i=0;【 】;i++)
if(【 】)
{
t=1;
break;
}
if (【 】)
return("yes!");
else
return("no!");
}
main()
{
char str[50];
printf("Input;");
scanf("%s",str);
printf("%s\n",fun(str));
}
第14题:
以下程序的输出结果是______。main(){ char a[]="programming",b[]="language"; char *p1,*p2; int i; p1=a;p2=b; for(i=0;i<7;i++) if(*(p1+i)==*(p2+i))printf("%c",*(p1+i));}
A.gm
B.rg
C.or
D.ga
第15题:
有以下程序 void fun(char *a,char *b) { a=b; ( *a)++; } main() {char cl='A',c2='a',*p1,*p2; p1=&c1;p2:&c2; fun(p1,p2); printf("%c%c\n",c1,c2); } 程序运行后的输出结果是
A.Ab
B.aa
C.Aa
D.Bb
第16题:
以下程序#include<stdio.h>#include<string.h>main(){ char*p1="abc",*p2=-"ABC", str, [50]="xyz"; strcpy(str+2,strcat(p1,p2)); printf("%s\n", str);}
A.xyzabcABC
B.zabcABC
C.yzabcABC
D.xyabcABC
第17题:
有以下程序: void fun(char* a,char* B) ; { a=b; (*A) ++; } main() { char c1='A',c2='a',*p1,*p2; p1=&cl; p2=&c2: fun(p1,p2); printf("%c%c\n",c1,c2); } 程序运行后的输出结果是
A.Ab
B.aa
C.Aa
D.Bb
第18题:
有以下程序: void fun (char *a,char *b) { a=b;(*a)++;} main() { char cl='A',c2='a',*p1,*p2; p1=&c1;p2=&c2;fun (p1,p2); printf("%c,%c\n",c1,c2); } 程序运行后的输出结果是( )。
A.Ab
B.aa
C.Aa
D.Bb
第19题:
已定义以下函数 fun(char*p2,char*p1) { while((*p2=*pl)!='\0'){p1++;p2++;}} 函数的功能是
A.将p1所指字符串复制到p2所指内存空间
B.将p1所指字符串的地址赋给指针p2
C.对p1和p2两个指针所指字符串进行比较
D.检查p1和p2两个指针所指字符串中是否有'\0'
第20题:
有以下程序: #include<stdio.h> #include!(string.h> void fun(char*w,int m) { char S,*pl,*p2; p1=w;p2=w+m-; while(pl<p2){s=*pl; *p1=*p2; *p2=s;pl++;p2-;} } main( ) { char a[]="l23456"; fun(a,strlen(a));puts(a); } 程序运行后的输出结果是( )。
A.654321
B.116611
C.161616
D.l23456
第21题:
以下程序运行后的输出结果是______。 main() { char a[]="ABCDEFGH",b[]="abCDefGh"; char*p1,*p2;int k; p1=a;p2=b; for(k=0;k<=7;k++) if*(p1+k)==*(p2+k))printf("%c",*(p1+k)); printf("\n"); }
A.ABCDEFG
B.CDG
C.abcdefgh
D.abCDefGh
第22题:
试题35
有以下程序
#include <stdio.h>
#include <string.h>
void fun(char *w,int m)
{ char s, *p1, *p2;
p1=w; p2=w+m-1;
while(p1<p2){s=*p1; *p1=*p2; *p2=s; p1++; p2- -;}
}
main()
{ char a[]=”123456”;
fun(a, strlen(a)); puts(a);
}
程序运行后的输出结果是()
A.654321
B.116611
C.161616
D.123456
第23题:
aa
ma
am
mm