计算机二级

设有以下语句: char str[4][12]={"aaa","bbbb","ccccc","dddddd"},*strp[4]; int i; for(i=0;i<4;i++) strp[i]=str[i]; 下列选项不是对字符正确引用的是(其中0≤k<4)( )。A.strpB.str[k][k]C.* strp[k]D.** strp

题目

设有以下语句: char str[4][12]={"aaa","bbbb","ccccc","dddddd"},*strp[4]; int i; for(i=0;i<4;i++) strp[i]=str[i]; 下列选项不是对字符正确引用的是(其中0≤k<4)( )。

A.strp

B.str[k][k]

C.* strp[k]

D.** strp

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

第1题:

【单选题】设有以下程序段: char str[4][10]={“frist”,”second”,”third”,”forurth”},*strp[4]; int n; for(n=0;n<4;n++) strp[n]=str[n]; 若k为int型变量且0<=k<4,则对字符串的不正确引用是()。

A.strp

B.str[k]

C.strp[k]

D.*strp


*p与s[0]相等

第2题:

设有以下语句,若0<k<4,下列选项中不能对数组中字符串的正确引用的是()。 char str[4][12]={"aaa","bbb","ccc","ddd"},*strp[4]; int j; for(j=0;j<4;j++) strp[j]=str[j];

A.*strp

B.strp

C.strp[k]

D.str[k]


C

第3题:

【单选题】设有以下定义语句,则引用正确(可以得到有效字符或字符串)的是()。 char strp[4][12]={"aaa","bbbb","ccccc","dddddd"};

A.strp[0][3]

B.strp[2]

C.strp[4]

D.strp[1][4]


int y[5]={0,1,3,5,7,9} ;

第4题:

设有以下语句,若0<k<4,下列选项中不能对数组中字符串的正确引用的是()。 char str[4][12]={"aaa","bbb","ccc","ddd"},*strp[4]; int j; for(j=0;j<4;j++) strp[j]=str[j];

A.strp

B.*strp

C.strp[k]

D.str[k]


C

第5题:

下列程序的输出结果是 #include void main( ) { char * str="12123434"; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!='\0';i++) switch(str[i]) { case'1':x4++; case'2':x3++; case'3':x2++; case'4':x1++; } cout < < x1 < < "," < < x2

A.8,6,4,1

B.8,6,3,2

C.8,8,4,1

D.8,6,4,2


正确答案:D
解析:本题考查循环的嵌套。只要注意在c++语言中,系统在字符指针的最后位置会增加一个字符串结束符'\0',执行8次for循环,再根据switch语句中的条件易知答案。注意:C++中各种条件判断,循环语句的用法。

第6题:

下列程序的输出结果是includevoid main(){char*str="12123434";int x1=0,x2=0,x3=0

下列程序的输出结果是 #include<iostream.h> void main() {char*str="12123434"; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!='\0';i++) switch(str[i]) {case'1':x4++; case'2':X3++; case'3':X2++; case'4':X1++; } cout<<X1<<","<

A.8,6,4,1

B.8,6,3,2

C.8,8,4,1

D.8,6,4,2


正确答案:D

第7题:

以下程序的输出结果是______。 fun(int *s,int *p) { static int t=3; *p=s[t]; t--; } main() { int str[]={1,2,3,4},i,m=0; for(i=0;i<4;i++) {fun(str,&m); printf("%d",m); } printf("\n"); }

A.0

B.444412

C.1234

D.4321


正确答案:D
解析:程序的功能是将字符数组str中的内容以反序输出。函数fun中t为静态变量,每一次调用函数fun时,t的值为上一次调用函数结束时的值。

第8题:

下列程序的输出结果是( )。include<iostream.h>voidmain() (char*str="12123434&quo

下列程序的输出结果是( )。#include<iostream.h>

voidmain()

(char*str="12123434";

intx1=0,x2=0,x3=0,x4=0,i;

for(i=0;str[i]!='\0';i++)

switch(str[i])

{case'1':x4++;

case'2':x3++;

case'3':x2++;

case'4':x1++;

}

cout<<x1<<","<<x2<:<","<<x3<

<","<<x4;

}

A.8,6,4,1

B.8,6,3,2

C.8,8,4,1

D.8,6.4,2


正确答案:D
D。【解析】本题考查循环的嵌套、for和switch语句的应用、C++中各种条件判断,循环语句的用法。只要注意在C++语言中,系统在字符指针的最后位置会增加一个字符串结束符'\0',执行8次for循环,再根据switch语句中的条件易知答案。

第9题:

下列程序的输出结果是()。includevoid main(){char*str=”12123434”;int x1=0,x2=0,x

下列程序的输出结果是( )。 #include<iostream.h> void main() {char*str=”12123434”; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!=’\0’;i++) switch(str[i]) {case’1’:x4++; case’2’:x3++; case’3’:x2++; case’4’:xl++; ) cout<<xl<<“,”<<x2<<

A.8,6,4,1

B.8,6,3,2

C.8,8,4,l

D.8,6,4,2


正确答案:D
解析: 本题考查循环的嵌套,for和switch语句的应用。C++中。各种条件判断,循环语句的用法。只要注意在C++语言中,系统在字符指针的最后位置会增加一个字符串结束符'\0’,执行8次for循环,再根据,witch语句中的条件易知答案。