编写一个程序,要求用户输入每日降雨量。您的程序将需要接受5个每日降雨量输入。仅允许非负降雨量。当用户输入一个负数时,告诉他们该数字无效,并且应该输入另一个有效值。
计算总降雨量和平均降雨量。确定最大的每日降雨量和最小的每日降雨量。
使用信息性消息输出总,平均值,最大值和最小值。
以下内容不会在main中发生:
==============================================>
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5 // have the user enter it 5 times
double CollectRainfall() {
double amount;
double rainfall[SIZE];
int i;
printf("Enter a rainfall amount: \n"); // enter amount
scanf_s("%lf", &amount);
for (i = 0; i < SIZE; i++) {
rainfall[i] = CollectRainfall();
while (amount < 0.0) { // if it's a negative number
printf("The number is invalid.\n"); // display error message if a negative # was entered
printf("Enter another rainfall amount: \n");
}
}
}
int main() {
CollectRainfall();
return 0;
}
编写一个程序,要求用户输入每日降雨量。您的程序将需要接受5个每日降雨量输入。仅允许非负降雨量。当用户输入否定的...
您可以创建一个结构来存储您的数据并执行操作。