阅读下列程序,当运行函数时,输入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;
printf("Input a string : ");
gets(str);
puts(str);
fun(str);
printf("%s\n",str);
}
A.asdafaaz67
B.asd af aa z67
C.asd
D.z67
第1题:
阅读以下程序 #include<iostream.h> void main() { charline[10]; in>>line; cout<<line<<endl; } 如运行时输入This is an example.<CR>,则程序的输出结果是( )。
A.This
B.This is
C.This is a
D.This is an example.
第2题:
阅读以下程序
#include<iostream.h>
void main( )
{
char line[10];
cin>>line;
cout<<line<<endl;
}
如运行时输入This is example.<CR>,则程序的输出结果是
A.This
B.This is
C.This is a
D.This is an example.
第3题:
编写一个函数,该函数可以统计一个长度为2的字符串在另一个字符串中出现的次数。例如,假定输入的字符串为asd asasdfg asd as zx67 asd mklo,子字符串为as,则应当输出6。
注意:部分源程序给出如下。
请勿改动主函数main和具他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
int fun(char *str, char *substr)
{
}
main ( )
{
char str[81],substr[3];
int n;
clrscr ();
printf ("输入主字符串 ");
gets (str);
printf ("输入子字符串");
gets (substr);
puts (str);
puts (substr);
n=fun (shr, substr);
printf("n=%d\n ",n);
}
第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题:
当执行下面的程序时,如果输入ABC,则输出结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char ss [10] ="12345"; gets(ss);strcat(ss"6789");printf("%s\n",ss); }
A.ABC6789
B.ABC67
C.12345ABC6
D.ABC456789
第6题:
阅读下列程序,当运行函数时,输入asd af aa z67,则输出为
#include
#include
#include
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.asd af aa z67
C.asd
D.z67
第7题:
下列程序运行后,如果从键盘上输入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
第8题:
阅读下列程序,当运行函数时,输入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];
A.asdafaaz67
B.asdafaa267
C.asd
D.z67
第9题:
以下程序运行后,如果从键盘上输入ABCDEF<回车>,则输出结果为______。 #include<stdio.h> #include<string.h> func(char str[]) { int num=0; while(*(str+num)!='\0') num++; return(num);p } main() { char str[10],*p=str; gets(p);printf("%d\n",func(P)); }
A.8
B.7
C.6
D.5
第10题:
有以下程序 #include<stdio.h> main() { int a=5,b=lt; t=(a<<2)|b;printf("%d\n",t); } 程序运行后的输出结果是______。
A.21
B.11
C.6
D.1