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

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


相似考题
更多“阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include <stdio.h>#include <ctype.h>#i ”相关问题
  • 第1题:

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

  • 第2题:

    阅读下列程序,当运行程序时,输入asd af aa z67,则输出为()。includeint fun (char *str

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


    正确答案:A
    解析:本题题意是删除字符串中所有空格。由于C语言中没有直接删除字符的操作,所以删除字符的操作都是采用“留下”字符的算法来实现。从串头str[0]到串尾逐一比较,判断其是否为空格,若不是空格,则将其保存在str[j]中,最后加串结束符“\0”。

  • 第3题:

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


    -125=-5*5*5

  • 第4题:

    请补充main函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。

    注意:部分源程序给出如下。

    请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。

    试题程序:

    include<stdio.h>

    include<ctype.h>

    main()

    {

    int i=0;

    char a [81];

    char *p=s;

    clrscr ();

    printf{" Input a string \n");

    for (i=0; i<80; i++)

    {

    s [i] =getchar ( );

    if (s [i]=='\n')

    【 】;

    }

    s[i]=【 】

    printf(" display the string \n");

    while (*p)

    putchar (【 】);

    }


    正确答案:break '/0' *P++
    break '/0' *P++ 解析:第一空:当输入的字符是回车符时,使用break语句跳出for循环,结束输入。第二空:结束输入后,在字符串s最后要加上结束标记符,'\0' 。第三空:最初指针p指向字符串s的首字符,通过P慢逐一指向后面的每个字符,调用putchar()函数输出字符。

  • 第5题:

    C语言本身有提供输入输出语句,但是要使用标准的I/O库函数(即输入/输出库函数),须在程序头加入#include “stdio.h”。()


    正确