编写程序,要求找到用户输入的一串数中的最大数。程序需要提示用户一个一个输入数。当用户输入0或负数时,程序必须显示输入的最大非负数:
![](https://i-blog.csdnimg.cn/blog_migrate/b77b86a06880accbd0f54c32057c5200.png)
#include <stdio.h>
main() {
float i, j;
printf("Enter a number:");
scanf("%f", &i);
while (i > 0) {
printf("Enter a number:");
scanf("%f", &j);
if (j > 0) {
if (i < j) i = j;
}
else break;
}
printf("The largest number entered was %f", i);
return 0;
}