Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
101264 | 罗迎甲 | 18患病人数占总患病人数的比例 | C++ | Compile Error | 0 MS | 0 KB | 842 | 2024-12-14 17:26:13 |
#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 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 << '%' << ' '; cout << fixed << setprecision(2) << c / n * 100.0 << '%' << ' '; cout << fixed << setprecision(2) << d / n * 100.0 << '%' << ' '; cout << fixed << setprecision(2) << e / n * 100.0 << '%' << endl; return 0; }
Main.cc:9:1: error: 'cin' does not name a type cin >> n; ^ Main.cc:10:1: error: expected unqualified-id before 'for' for (int i = 0; i < n; i++) { ^ Main.cc:10:17: error: 'i' does not name a type for (int i = 0; i < n; i++) { ^ Main.cc:10:24: error: 'i' does not name a type for (int i = 0; i < n; i++) { ^ Main.cc:15:1: error: expected unqualified-id before 'for' for (int i = 0; i < n; i++) { ^ Main.cc:15:17: error: 'i' does not name a type for (int i = 0; i < n; i++) { ^ Main.cc:15:24: error: 'i' does not name a type for (int i = 0; i < n; i++) { ^ Main.cc:26:1: error: 'cout' does not name a type cout << fixed << setprecision(2) << b / n * 100.0 << '%' << ' '; ^ Main.cc:27:1: error: 'cout' does not name a type cout << fixed << setprecision(2) << c / n * 100.0 << '%' << ' '; ^ Main.cc:28:1: error: 'cout' does not name a type cout << fixed << setprecision(2) << d / n * 100.0 << '%' << ' '; ^ Main.cc:29:1: error: 'cout' does not name a type cout << fixed << setprecision(2) << e / n * 100.0 << '%' << endl; ^ Main.cc:30:1: error: expected unqualified-id before 'return' return 0; ^ Main.cc:32:1: error: expected declaration before '}' token } ^