-
Title Description:
-
There are several students in the class, giving the age of each student (whole number), the average age of all students in the class, and the retention of two decimal places.
-
Input:
-
The first line has an integer n (1<= n <= 100) that represents the number of students. The next n rows have 1 integers per line, with values from 15 to 25.
-
Output:
-
There may be multiple sets of test data, for each set of data,
The output row, which contains a floating-point number, is reserved to two digits after the decimal point for the required average age.
-
Sample input:
-
21817
-
Sample output:
-
17.50
-
Tips:
-
To output floating-point numbers, double-precision digits after the decimal 2 digits, you can use the following form:
printf ("%.2f", num);
-
Source:
- 2008 Beijing University founder Laboratory Computer Research The real problem of life test
#include <iostream>#include<iomanip>using namespacestd;intMain () {intN; while(cin>>N) { Doublesum=0; for(intI=0; i<n;i++){ DoubleA; CIN>>A; Sum+=A; } Doubleaverage; cout<<fixed<<setprecision (2) <<average<<Endl; } return 0;}
1128. Ask for the average age