阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include<stdio.h>#include<ctype.h>#inc

题目
阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeinc

阅读下列程序,当运行函数时,输入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

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

第1题:

如果下列程序正常运行,则当从键盘输入字母A时,输出结果为()。  #include <stdio.h>  main()     {  char ch;       ch=getchar();      switch(ch)      {  case 65: printf(“%c”, ‘A’);       case 66: printf(“%c”, ‘B’);       default: printf(“%s”, “other”);    }    }

A.A

B.AB

C.ABother

D.不确定


D scanf函数读取的是char型数据,所以回车时输入的换行符也是有效字符。于是c1,c2,c3,c4的内容分别是1,2,3,ˊ\nˊ。

第2题:

12、一个C语言源程序中如果调用了函数fabs,那必须有编译预处理命令()。

A.#include <stdio.h>

B.#include <math.h>

C.#include <ctype.h>

D.#include <stdlib.h>


#include

第3题:

使用scanf函数需要在头文件中添加___.

A.#include <stdio.h>

B.#include <ctype.h>

C.#include <float.h>

D.include <iomanip.h>


C

第4题:

有以下程序,当输入数据为:12.5时,程序输出结果是()。 #include "stdio.h" main() { int a; scanf("%d",&a); printf("a=%dn",a); }


-125=-5*5*5

第5题:

当执行下面程序且输入"ABC"时,则输出的结果是()。 #include <stdio.h> #include <string.h> main() { char a[10]="12345"; strcat(a,"6789"); gets(a); printf("%s",a); }

A.ABC

B.ABC9

C.123456ABC

D.ABC456789


Astrcat函数,gets函数;首先将输入的字符串赋给ss,然后将字符串“6789”连接到ss得后

第6题:

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeine

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include <stdio.h> #include <ctype.h> #inelude <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


正确答案:A
解析:本题题意要求删除所有空格,即除了空格以外的其他所有字符都要留下。由于C语言中没有直接删除字符的操作,所以我们对于删除字符的操作都是采用“留下”字符的算法,以前的题目亦是如此。用str[i]从串头到串尾逐一走动,每走到一个字符都判断其是否为空格,若不是空格(注意在if()的单引号之间有一个空格),则将其保存str[j]中。注意 j的下标变化、初值及最后加串结束符“\0”。

第7题:

下列程序运行后,如果从键盘上输入ABCDE<回车>,则输出结果为______。includeinclude

下列程序运行后,如果从键盘上输入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


正确答案:D

第8题:

阅读下列程序,当运行函数时,输入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


正确答案:A

第9题:

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为include include i

阅读下列程序,当运行函数时,输入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


正确答案:A
解析: 本题题意要求删除所有空格,即除了空格以外的其他所有字符都要留下。由于C语言中没有直接删除字符的操作,所以我们对于删除字符的操作都是采用“留下”字符的算法,以前的题目亦是如此。用str[i]从串头到串尾逐一走动,每走到一个字符都判断其是否为空格,若不是空格(注意在if()的单引号之间有一个空格),则将其保存str[j]中。注意j的下标变化、初值及最后加串结束符'\0'。