C++简洁代码:
#include<bits/stdc++.h> using namespace std; int main() { float temp, res = 0; while(cin >> temp) res += temp; printf("%.2f",0.2 * res); //方法一,C语言 //cout << setiosflags(ios::fixed) << setprecision(2); //方法二,c++ //cout << 0.2 * res <<endl; return 0; }