Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
101260 欧阳俊懿 18患病人数占总患病人数的比例 C++ Compile Error 0 MS 0 KB 716 2024-12-14 17:21:02

Tests(0/0):


Code:

include<bits/stdc++.h> 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; }


Run Info:

Main.cc:1:1: error: 'include' does not name a type
 include 
 ^
Main.cc: In function 'int main()':
Main.cc:9:1: error: 'cin' was not declared in this scope
 cin >> n;  
 ^
Main.cc:29:1: error: 'cout' was not declared in this scope
 cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl;  
 ^
Main.cc:29:9: error: 'fixed' was not declared in this scope
 cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl;  
         ^
Main.cc:29:32: error: 'setprecision' was not declared in this scope
 cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl;  
                                ^
Main.cc:29:61: error: 'endl' was not declared in this scope
 cout << fixed << setprecision(2) << b / n * 100.0 << '%' << endl;  
                                                             ^