NAME0
NAMEE
NAME
NAME\0
第1题:
有以下程序: # include<string.h> main() { char str[][20]={"Hello","Beijing"},*p=str; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是 ______。
A.0
B.5
C.7
D.20
第2题:
下列程序运行后,如果从键盘上输入ABCDE<回车>,则输出结果为______。 #include<stdio.h> #include<string.h> fuch (char str[] ) { int num=0; while (*(str+num)!='\0')num++; return(num); } main() { char str[10],*p=str; gets(p);printf("%d\n",fuch(p)); }
A.8
B.7
C.6
D.5
第3题:
以下C程序段的输出结果是(30)。 #include <stdio. h> void abc(char *str){ int a, b; for(a=b=0;str[a]!='\O';a++)if(str[a]!='c') str[b++]=str[a]; str[b]='\O'; } void main(){ char str[]="abcdef"; abc(str); printf("str[]=%s",str); }
A.str[]=a
B.str[]=ab
C.str[]=abdef
D.str[]=abcdef
第4题:
如下程序段#include <stdio.h>#include <ctype.h>#include <conio.h>int fun (char *str){ int i,j=0; for(i=0;str[i]!= ’\0’;i++) if(str[i]!= ’ ’)str[j++]=str[i]; str[j]= ’\0’;}main(){ char str[81]; int n; clrscr(); printf("Input a string : "); gets(str); fun(str); printf("%s\n",str);}当运行程序时,输入asd af aa z67<回车>,则输出是A.asdafaaz67 B.asd af aa z67 C.asd D.z67
第5题:
以下程序的输出结果是【 】。
include <stdio.h>
include <string.h>
char *fun(char *0
{ char *p--t;
return (p+strlen(t)/2);
}
main()
{ char *str="abcdefgh";
str=ftm(str);
puts(str);
}
第6题:
下列程序的输出结果是______。 char*fun(char*str,int n) { int i; char*p=str; for(i=0;i<10;i++,str++) *str='a'+i; return++p; } main() { char a[10]; printf("%s\n",fun(a,10)); }
A.ABCDEFGHIJ
B.abcdefghij
C.bcdefghij
D.不确定的值
第7题:
若有以下程序:
include <iostream>
using namespace std;
int main()
{
char str[10];
cin>>str;
cout<< str<<end1;
return 0;
}
当输入为:
This is a program!
那么执行程序后的输出结果是【 】。
第8题:
阅读下面程序,程序执行后的结果为( )。 #include"stdio.h" main() {char*str="abcdefghijklnmopq": while(*str++!='e'); printf("%c\n",*str); }
A.f
B.a
C.e
D.a
第9题:
有以下程序: #include <stdio.h> #include <string.h> main() { char str[][20]={"Hello","Beijing"},*P=str[0]; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是( )。
A.0
B.5
C.7
D.20
第10题:
当运行以下程序时,输入abcd,程序的输出结果是:( )。
insert(char str[])
{int i;
i=strlen(str);
while(i>0)
{str[2*i]=str[i];str[2*i-1]='*';i--;}
printf("%s\n",str);
}
main()
{char str[40];
scanf("%s",str);insert(str);
}
第11题:
10,6,4,6
11,6,11,6
11,6,1,6
10,7,1,7
第12题:
C##123#0
C##1230
C##0
C##123#\0
第13题:
有如下程序: #include <iostream> using namespace std; int main() { char str[100], *p; cout<<"Please input a string:"; cin>>str; p=str; for (int i=0; *p!='\0'; p++,i++); cout<<i<<endl; return 0; }运行这个程序时,若输入字符串为 abcdefgabcd则输出结果是
A.7
B.12
C.13
D.100
第14题:
有以下程序:
include <iostream>
include <string>
using nameSpace std;
class person
{
int age;
Char * name;
public:
person ( int i, Char * str )
{
int j;
j = strlen( str ) + 1;
name = new char[ j ];
strcpy( name, str );
age = i;
}
~person()
{
delete name;
cout<<"D";
}
void display()
{
cout<<name<<":"<<age;
}
};
int main()
{
person demo( 30,"Smith" );
demo.display();
return 0;
}
则该程序的输出结果为:【 】。
第15题:
有以下程序: #include<string.h> main() { char str[][20]={"Hello","Beijing"),*p=str[0]; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是( )。
A.0
B.5
C.7
D.20
第16题:
下列程序的运行结果为( )。
#include<stdio.h>
voidabc(char*str)
{int a,b,i,j;
for(i=j=0;str[i]!='\0';i++)
if(str[i]!='a')
str[j++]=str[j];
str[j]='\0';
}
void main()
{char Str[]="abcdef';
abc(str);
printf("str[]=%s",str);
}
A.str[]=bcdef
B.str[]=abcdef
C.str[]=a
D.str[]=ab
第17题:
以下程序运行后输入:3,abcde<回车>,则输出结果是【 】
include <string.h>
move(char *str, int n)
{ char temp; int i;
temp=str[n-1];
for(i=n-1;i>0;i--) str[i]=str[i-1];
str[0]=temp;
}
main( )
{ char s[50]; int n, i, z;
scanf("%d,%s",&n,s);
z=strlen(s);
for(i=1; i<=n; i++) move(s, z);
printf("%s\n",s);
}
第18题:
有以下程序#include "stdio.h"main() { char str[]="tomeetme",str1[]="toseeyou"; char *p=str,*p1=str1; int i; for(i=0;i if(*(p+i)==*(p1+i)) putchar(*(p+i)); printf("\n");}程序的运行结果是A.to B.tomeetC.toeeD.程序段不能通过编译
第19题:
阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include<stdio.h> #include<ctype.h> #include<string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; clrscr(); printf("Input a string:"); gets(str); puts(str); fun(str); printf("%s\n",str); }
A.asdafaaz67
B.asdafaaz67
C.asd
D.z67
第20题:
阅读下列程序,当运行程序时,输入asd af aa z67,则输出为( )。 #include <sldio.h> int fun (char *str) { int i,j=0; for(i=0;str[i]! ='\0';i++) if(str[i]! =") str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; printf("Input a string:"); gets(str); fun(str); printf("%s\n",str); }
A.asdafaaz67
B.asd af aa z67
C.asd
D.z67
第21题:
下列程序的输出结果是______。
include<iostream.h>
int CalcDigital(char*str)
{
if(str= =NULL)
return 0;
int num_of_digital=0;
for(int i=0;str{i]!=0x0;i++)
if(str[i]<='9'&& str[i]>='0')
num_of_digital++;
return num_of_digital;
}
void main( )
{
char a[]="Beijing20080lympic";
cout<<CalcDigital(a)<<endl;
}
第22题:
下列程序的输出结果是 ()。 #include
第23题:
9,7,4,7
8,6,9,6
8,6,3,6
10,8,5,8