The average number of

topic:

3 integer input, outputs their average value, three decimal places.

 

Ideas:

It can be calculated directly.

 

Code:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int a = 0, b = 0, c = 0;
cin >> a >> b >> c;
double average = static_cast<double >(a + b + c) / 3;
cout << setprecision(3) << fixed << average << endl;

return 0;
}

Guess you like

Origin www.cnblogs.com/Hello-Nolan/p/12110149.html