For each illegal input number, print in a line ERROR: X is not a legal number where X is the input. Then finally print in a line the result: The average of K numbers is Y where K is the number of legal inputs and Y is their average, accurate to 2 decimal places. In case the ...
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real number in [−1000,1000] and is accurate up to no more than 2 decimal places. When...
The average of 3 numbers is 1.38 Sample Input 2:2aaa -9999 Sample Output 2:ERROR: aaa is not a legal numberERROR: -9999 is not a legal numberThe average of 0 numbers is Undefined #include <iostream> #include <cstdio> #include <string.h> using namespace std; int main() { int n...
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real number in [−1000,1000] and is accurate up to no more than 2 decimal places. When...
Create a float variable called runningTotal. Then, create a for in loop which iterates through the array you created in step 1. When the loop finishes running, the value of 'average' should be the average of the values contained in temp. ...
Previously, we reported that the Disneey sequel surpassed Frozen II’s $130 million debut within around three days of its release. The industry anticipated the total numbers after the first weekend, and they are far more incredible. The film brought a wave of new records for upcoming films ...
They now say the light from our universe is closer to white. It is more like a milky or creamy white color. The scientists gave a number to each of the colors of the different star systems. Then they added the numbers together and found the average measurement. The scientists used this...
The average of3numbersis1.38 Sample Input 2: 2aaa-9999 Sample Output 2: ERROR: aaaisnot a legal number ERROR:-9999isnot a legal number The average of0numbersisUndefined AC【找平均数】三部曲:1、[ 判断合法 ] 2、[ 记录合法 ] 3、[ 分类输出 ] ...
The average of 3 numbers is 1.38 Sample Input 2: 2 aaa -9999 Sample Output 2: ERROR: aaa is not a legal number ERROR: -9999 is not a legal number The average of 0 numbers is Undefined 思路 逻辑题,注意处理下负数的情况,其余按题目要求设置好if语句的条件就行。
printf("The average of 1 number is %.2f",sum); elseif(cnt>1) printf("The average of %d numbers is %.2f",cnt,sum/cnt); else printf("The average of 0 numbers is Undefined"); system("pause"); return0; } 1. 2. 3. 4. ...