永发信息网

请帮忙做下C语言的题目

答案:2  悬赏:20  手机版
解决时间 2021-04-21 10:56
  • 提问者网友:捧腹剧
  • 2021-04-20 22:49

一.改错题 将横线所在行的错误改正后写在横线上。

1、下面程序的功能是从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩,当输入为负数时结束输入。
  void main()
   { float x, amax, amin;
scanf("%f", x); ________________________
amax=x;
amin=x;
      while(x>=0); ________________________
       { if (x>amax) amax=x;
        if (x>amin) amin=x; ________________________
        scanf ("%f", &x);
       }
     printf("\namax=%f amin=%f\n", amax,amin);
    }

二.改错题 (请将横线所在行的错误改正后写在横线上。)

下面程序的功能是:输入一行字符,统计其中的英文字符、数字字符、空格字符,以及其他字符的个数。

void main()

{ char str[100]; int len, i, letter=0, digit=0, space=0, other=0;

printf("请输入一个字符串:");

gets(str);

len = strlen(str);

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

{ if (a=<str[i]<=z && A=<str[i]<=Z) ________________________

++letter;

else

if (0=<str[i]<=9) ________________________

++digit;

else

if (str[i]=' ' ) ________________________

++space;

else

++other;

}

printf("letter=%d", letter);

printf("digit=%d", digit);

printf("space=%d", space);

printf("other=%d", other);

}

最佳答案
  • 五星知识达人网友:深街酒徒
  • 2021-04-20 22:57

1、下面程序的功能是从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩,当输入为负数时结束输入。
  void main()
   { float x, amax, amin;
scanf("%f", x); __scanf("%f",_&x)_____________________
amax=x;
amin=x;
      while(x>=0); _______while(x>=0)_________________
       { if (x>amax) amax=x;
        if (x>amin) amin=x; _________if (x<amin) amin=x; _______________
        scanf ("%f", &x);
       }
     printf("\namax=%f amin=%f\n", amax,amin);
    }


二.改错题 (请将横线所在行的错误改正后写在横线上。)


下面程序的功能是:输入一行字符,统计其中的英文字符、数字字符、空格字符,以及其他字符的个数。


void main()


{ char str[100]; int len, i, letter=0, digit=0, space=0, other=0;


printf("请输入一个字符串:");


gets(str);


len = strlen(str);


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


{ if (a=<str[i]<=z && A=<str[i]<=Z) ___{ if ((str[i]>='a'&&str[i]<='z') ||(str[i]>='A'&&str[i]<='Z')) ___


++letter;


else


if (0=<str[i]<=9) ________if(str[i]>='0'&&str[i]<='9')_______


++digit;


else


if (str[i]=' ' ) __________if (str[i]==' ' ) __________


++space;


else


++other;


}


printf("letter=%d", letter);


printf("digit=%d", digit);


printf("space=%d", space);


printf("other=%d", other);


}

全部回答
  • 1楼网友:长青诗
  • 2021-04-21 00:20

scanf("%f", x); ( scanf("%f", &x); )

while(x>=0); ( while(x>0); )

if (x>amin) amin=x ( if (x<amin) amin=x )

if (a=<str[i]<=z && A=<str[i]<=Z) ( if ('a'=<str[i]<='z' && 'A'=<str[i]<='Z') )

if (0=<str[i]<=9) ( if ('0'=<str[i]<='9') )

if (str[i]=' ' ) ( if (str[i]==' ' ) )

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯