计算机二级

以下程序运行后,输出结果是______。includess(char*s){char *p=s; while(*.p)p++; retu以下程序运行后,输出结果是______。#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.8B.7C.6D.5

题目
以下程序运行后,输出结果是______。includess(char*s){char *p=s; while(*.p)p++; retu

以下程序运行后,输出结果是______。#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

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

【填空题】写出下面程序执行后的运行结果。 #include <iostream> #include <string> using namespace std; char* ss____ { char*p, t; p = s + 1; t = *s; while ____ { *____ = *p; p++; } *____ = t; return s; } void main____ { char *p, str[10]="abcdefgh"; p = ss____; cout << p; }


a=1,b=111

第2题:

以下程序运行后的输出结果是______。 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


正确答案:D

第3题:

以下程序运行后,输出结果是()includess(char*s){char*p=s; while(*p)p++ return(p-s);

以下程序运行后,输出结果是( ) #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


正确答案:D

第4题:

下列程序运行后,输出结果是______。 include include fun(char *w ,int

下列程序运行后,输出结果是______。 #include <stdio. h> #include <string. h> fun (char *w ,int n) { char t,*s1,*s2; s1=w; s2=w+n-1; while (s1<s2) { t=*s1++; *s1=*s2--; *s2=t; } } main () { char *p; p="1234567"; fun (p, strlen (p)); puts (p); }

A.1234567

B.7654321

C.1711717

D.7177171


正确答案:C

第5题:

以下程序的输出结果是()。includeint fun (char*s){char *p=s;while (*p!='\0,) p++

以下程序的输出结果是( )。 #include<iostream.h> int fun (char*s) { char *p=s; while (*p!='\0,) p++: return (p-s): } void main() { cout<<fun (" ABCDEF ")<<endl: }

A.3

B.6

C.8

D.0


正确答案:B

第6题:

请读程序: includef(char * s){cahr * p=s;while(* p!='\0')p++;return(p-s);}main(){

请读程序: # 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


正确答案:B

第7题:

有以下程序: include void funl (char * p){char * q; q=p; while( *q! ='\0') } (*q)

有以下程序: #include <stdio.h>void funl (char * p){ char * q; q=p; while( *q! ='\0') } (*q) ++;q++;}mains( ){ char a[ ] = { "Program" } , * p; p = &a[3]; fun1 (p); printf("% s \n" ,a);}程序执行后的输出结果是( )。

A.Prohsbn

B.Prphsbn

C.Progsbn

D.Program


正确答案:A
解析:在main函数中,p=&a[3]说明指针p指向a数组的第4个字符(即字符'g');fun1中的q=p意味着指针q也指向了a数组的第4个字符。执行while语句,表达式(*q)++使'g'+1,使'g'变成了'h';表达式q++使q指向a[4]的起始地址。继续执行while语句,直到遇到'\0'结束循环,返回形参。最终得到的结果是从字符串"Program'的第4个字符开始,每个字符加1。

第8题:

以下程序运行后的输出结果是( )。

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);

}


正确答案:bcdefgha
bcdefgha

第9题:

下列程序的输出结果是______。 includef(char 8s){char *p=s;while(*p!='\0')p++;retur

下列程序的输出结果是______。# 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


正确答案:B