练习一下C++精度设置
#include<iostream> #include<iomanip> using namespace std; int main() { int n, num; while (cin >> n) { float sum = 0; for(int i = 0; i < n; i ++){ cin >> num; sum += num; } cout << fixed << setprecision(2) << sum / n << endl; } return 0; }