Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
101271 罗迎甲 18患病人数占总患病人数的比例 C++ Compile Error 0 MS 0 KB 916 2024-12-14 17:31:43

Tests(0/0):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n; double b = 0, c = 0, d = 0, e = 0, a[1000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i] <= 18) { b++; } else if (a[i] >= 19 && a[i] <= 35) { c++; } else if (a[i] >= 36 && a[i] <= 60) { d++; } else { e++; } } cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl; cout << fixed << setprecision(2) << c / n * 100.0 << '%' << endl; cout << fixed << setprecision(2) << d / n * 100.0 << '%' << endl; cout << fixed << setprecision(2) << e / n * 100.0 << '%' << endl; return 0; } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:31:32: error: 'setprecision' was not declared in this scope
 cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl;  
                                ^
Main.cc: At global scope:
Main.cc:37:5: error: expected unqualified-id before 'return'
     return 0;
     ^
Main.cc:38:1: error: expected declaration before '}' token
 }
 ^