Home > Back-end > Input a number of natural Numbers, the last is 0 (end of said input), the output is greater than the
Input a number of natural Numbers, the last is 0 (end of said input), the output is greater than the
Time:09-16
#include using namespace std; Int main () { Int a, b; Float c; int n; For (a=0, b=0;; +, b +=n, c=1.0 * b/a){ Cin> n; If (n==0) break; } Cout<& lt;" The average="& lt; return 0; } This want how to just can make the output is the result of the "greater than the average number of"
CodePudding user response:
Using a container to the input values are stored, calculate the average, in comparing the
CodePudding user response:
Or an array input number
CodePudding user response:
Not very understand, can you help me to change
CodePudding user response:
For reference array version of
#include using namespace std; Const int N=1024;
Int main () { Int arr [N]. Int I, a=0, b=0, count=0; Float c;
for (i=0; I{ Cin & gt;> Arr [I]; B +=arr [I];
If (arr [I]==0) { A=I; break; } }
C=b * 1.0/a; for (i=0; I{ If (arr [I] & gt; C) count++; }
Cout<& lt;" The average="& lt; Cout & lt; <"Greater than the average number of:" & lt; return 0; }