C带你飞第14课问题
#include <stdio.h>int main()
{
float num = 0;
double sum = 0;
int status;
do
{
printf("请输入合法的数字:");
do
{
sum = sum + num;
status = scanf("%f", &num);
} while (getchar() != '\n' && status == 1);
} while(status == 1);
printf("结果是:%.2lf\n", sum);
return 0;
}
比如我输入1a1,为什么程序在运行到a的时候会跳出到while(status == 1)这层
而输入1a1a1a1a1a就不会跳出
页:
[1]