错误:p=s[0];正确:p=*s;
错误:p=s[0];正确:p=s[];
错误:p=s[0];正确:p=s;
错误:p=s[0];正确:p=&s;
第1题:
有以下程序: # include<stdio.h> main() { char*p,*q; p=(char *)malloc(sizeof(char)* 20);q=p; scanf("%s %s",p,q);printf("%s %s\n",p,q); } 若从键盘输入;abc def<回车>,则输出结果是 ______。
A.def def
B.abc def
C.abe d
D.d d
第2题:
下列给定程序中,函数fun()的功能是:在字符串的最前端加入n个*号,形成新串,并且覆盖原串。
注意:字符串的长度最长允许79。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序;
include <stdio.h>
include <strzng.h>
include <conio.h>
/*****************found***************/
void fun(char s[], int n)
{
char a[80],*p;
int i;
/*****************found***************/
s=p;
for(i=0; i<n; i++) a[i]='*';
do
{a[i]=*p;
/*****************found***************/
i++;
}while(*p);
a[i]=0;
strcpy(s,a);
}
main()
{ int n;char s[80];
clrscr();
printf("\nEnter a string:");gets(s);
printf("\nThe string\%s\n",s);
printf("\nEnter n(number of*):");scanf ("%d",&n);
fun(s,n);
printf("\nThe string after inster: \%s\n",s);
}
第3题:
请选出正确的程序段
A.int*p; scanf("%d",p); …
B.int*s,k; *s=100; …
C.int *s,k; char*p,c; s=&k; p=&c; *p='a'; …
D.int *s,k; char *p,e; s=&k; p=&c; s=p; *s=1; …
第4题:
下列程序的执行结果是______。 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
第5题:
有以下程序 #include <stdlib.h> main() { char *p,*q; p=(char*)malloc(sizeof(char)*20); q=p; scanf("%s %s",p,q); printf("%s %s\n",p,q); } 若从键盘输入:abc def<回车>, 则输出结果是
A.def def
B.abc del
C.abc d
D.d d
第6题:
若输入“abcdef”“abdef”,下述程序的输出结果为( )。 #include<stdio.h> #include<string.h> main { int n; char s1[20],s2[20],*p1,*p2; scanf("%s",s1); scanf("%S",s2); p1=s1; p2=s2; n=strcmp(p1,p2); printf("Vood\n",n); }
A. -1
B.0
C."abcdef"
D."abdef"
第7题:
请读程序: # includde<stdio.h> # include<string.> void fun(char * s) {char a[10]; strcpy(a,"STRING"); s=a; } main() { char*p; fun(p); print{("%s\n",p); } 上面程序的输出结果(表示空格) ( )
A.STRING
B.STRING
C.STRING
D.不确定的值
第8题:
请读程序: # include<stdio.h> Char fun(char*c) (if(c<='z'& & * c>='A') * c-='A'-'a' return * c; } main() { char s[81],* p=s; gets(s); while(* p) { * p=fun(p);putchar(* p);p + +; puchar('\n'); } 若运行时从键盘上输入OPEN THE DOOR <CR>(<CR>表示回车),则上面程序的输出结果是 ( )
A.oPEN tHE dOOR
B.ope the door
C.OPEN THE DOOR
D.Open The Door
第9题:
以下程序的输出结果是【 】。
char s[ ]="XYZQ";
void main(){
char *p;
for(p = s; p < s+4; p++)
cout<<p<<end1;
}
第10题:
有以下程序: #include<stdlib.h> main( ) { char *p ,* q; p=(char * )malloc(sizeof(char) * 20);q=p; scanf("%s%s",p,q); printf("%s%s\n",p,q); } 若从键盘输入:abc def<回车>,则输出结果是
A.def def
B.abc def
C.abc d
D.d d
第11题:
有以下程序: #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
第12题:
6
5
4
3
第13题:
下列程序的输出结果是______。# 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
第14题:
下面程序的运行结果是【 】。
include<iostream.h>
void main()
{
char s[]="9876",*p;
for(p=s;p<s+2;p++)
cout<<p;
}
第15题:
请选出正确的程序段______。
A.int*p
B.int*s,k;scanf(""%d"",p); *s=100;… ……
C.int*s,k;
D.int*s,k;char*p,c; char*p,e;s=&k;p=&c; p=&c;*p='a'; s=p;…… *s=1;……
第16题:
有以下程序 #include<stdlib.h> main() { char*p,*q; p=(char *)malloc(sizeof(char)*20);q=p; scanf(“%s%s”,p,q);printf(“%s%s\n”,p,q); } 若从键盘输入:abc def<回车>,则输出结果是
A.def def
B.abc def
C.abc d
D.d d
第17题:
以下正确的程序段是
A.cgar str[20]; scanf("%s",&str);
B.char*p; scanf("%s",p);
C.char str[20]; scanf("%s",&str[2])
D.char str[20],*p=str; scanf("%s",p[2]);
第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题:
以下正确的程序段是______。
A.int*p; scanf("%d",p);
B.int *s,k *s=100;
C.int*s,k; char*p,c; s=&k; p=&c; *p='a';
D.int*s,k; char*p,c; s=&k; p=&c; s=p; *s=1;
第20题:
下列程序中,正确的为______。
A.main() { int *pb=&b; float 1>=15.25; print f("%d\n" ,*pb); }
B.amin() { int a,*pa; a=10; *pa=a; prinffC%d",*pa); }
C.main() { char s[20]; char *ps=&s; scanf("%s",*p); printf("%s",*p); }
D.main() { char str[10]; int *ps=str[0]; str="abcdefg"; printf("%s",*p); }
第21题:
以下程序运行后的输出结果是【 】。
include<iostream.h>
void main(){
char s[]=“123456”,*p;
for(p=s; p<s+2; p++)
cout<<p<<end1;
}
第22题:
请选出下面正确的程序段( )。
A.int *s; scanf("%d",s); ┆
B.int *s,k; *s=100; ┆
C.int *s,k; char *p, c; s=&k; p=&c; *p='a'; ┆
D.int *s,k; char *p, c; s=&k; p=&c; s=p; *s=1; ┆
第23题:
请读程序: main() {char*p; chars[80]; scanf("%s",s); p=s[0]; printf("%s",p); } 请判断上面程序()