8 条题解
-
1余玺赫 (田所浩一) LV 6 @ 2023-3-11 21:23:41
#include<iostream> #include<iomanip> using namespace std; int main() { int n,tmp,a1=0,a2=0,a3=0,a4=0; cin>>n; for(int i=0;i<n;i++) { cin>>tmp; if(tmp<=18)a1+=1; else if(19<=tmp&&tmp<=35)a2+=1; else if(36<=tmp&&tmp<=60)a3+=1; else if(tmp>=61)a4+=1; } cout<<fixed<<setprecision(2); cout<<a1*100.0/n<<'%'<<endl; cout<<a2*100.0/n<<'%'<<endl; cout<<a3*100.0/n<<'%'<<endl; cout<<a4*100.0/n<<'%'<<endl; return 0; }
-
02024-10-11 22:42:10@
#include <stdio.h> #include <iostream> #include <math.h> #include<iomanip> #include<bits/stdc++.h> using namespace std; int main() { int a,b[100]; float c=0,d=0,e=0,f=0; cin>>a; for(int i=1;i<=a;i++){ cin>>b[i]; } for(int i=1;i<=a;i++){ if(0<=b[i]&&b[i]<=18){ c++; }else{ if(b[i]<=35){ d++; }else{ if(b[i]<=60){ e++; }else{ f++; } } } } c=c/a; d=d/a; e=e/a; f=f/a; cout<<fixed<<setprecision(2)<<c100; cout<<"%"<<endl; cout<<fixed<<setprecision(2)<<d100; cout<<"%"<<endl; cout<<fixed<<setprecision(2)<<e100; cout<<"%"<<endl; cout<<fixed<<setprecision(2)<<f100; cout<<"%"; return 0; }
-
02024-6-11 21:00:45@
#include<iostream> #include<iomanip> using namespace std; int main() { double n,tmp,a1=0,a2=0,a3=0,a4=0; cin>>n; for(int i=0;i<n;i++) { cin>>tmp; if(tmp<=18)a1+=1; else if(19<=tmp&&tmp<=35)a2+=1; else if(36<=tmp&&tmp<=60)a3+=1; else if(tmp>=61)a4+=1; } cout<<fixed<<setprecision(2); cout<<a1100.0/n<<'%'<<endl; cout<<a2100.0/n<<'%'<<endl; cout<<a3100.0/n<<'%'<<endl; cout<<a4100.0/n<<'%'<<endl; }
-
02024-5-18 15:57:07@
#include <bits/stdc++.h> #define maxn 300000 using namespace std; typedef long long ll; int n,a[maxn],h1,h2,h3,h4; double l; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]<=18) h1++; else if(a[i]<=35) h2++; else if(a[i]<=60) h3++; else h4++; } printf("%.2lf\%\n%.2lf\%\n%.2lf\%\n%.2lf\%",h1*100.0/n,h2*100.0/n,h3*100.0/n,h4*100.0/n); }
-
02023-9-10 11:39:42@
#include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int a[N],n,z1,z2,z3,z4; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; if(a[i]>=0 && a[i]<=18) { z1++; } else if(a[i]>=19 && a[i]<=35) { z2++; } else if(a[i]>=36 && a[i]<=60) { z3++; } else if(a[i]>=61) { z4++; } } cout<<fixed<<setprecision(2)<<z1*100.0/n<<"%\n"; cout<<fixed<<setprecision(2)<<z2*100.0/n<<"%\n"; cout<<fixed<<setprecision(2)<<z3*100.0/n<<"%\n"; cout<<fixed<<setprecision(2)<<z4*100.0/n<<"%\n"; return 0; }
-
02023-4-4 22:26:48@
#include<iostream> using namespace std; int n,a,b,c,d; void out(int x){ printf("%.2lf",100.0*x/n); cout<<"%\n"; } int main(){ int x; cin>>n; for(int i=1;i<=n;i++){ cin>>x; if(0<=x&&x<=18)a++; else if(x<=35)b++; else if(x<=60)c++; else d++; } out(a);out(b);out(c);out(d); return 0; }
-
02023-2-19 15:00:51@
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
int n,x,ans1 = 0,ans2 = 0,ans3 = 0,ans4 = 0;
cin>>n;
for(int i =1;i<=n;i++){
cin>>x;
if(0 <= x && x <= 18) ans1++;
else if(x<=35) ans2++;
else if(x<=60) ans3++;
else ans4++;
}
cout<<fixed<<setprecision(2);
cout<<1.0ans1 / n100<<"%"<<endl;
cout<<1.0ans2 / n100<<"%"<<endl;
cout<<1.0ans3 / n100<<"%"<<endl;
cout<<1.0ans4 / n100<<"%"<<endl;
}
-
02022-8-12 20:43:30@
#include <bits/stdc++.h> using namespace std; //0-18、19-35、36-60、more than 61 int p_q[101]; int main(void) { int n; cin >> n; float q0, q19, q36, q61; for (int i = 0; i <= n - 1; i++) { cin >> p_q[i]; } for (int i = 0; i <= n - 1; i++) { if (p_q[i] <= 18 && p_q >= 0) { q0++; } if (p_q[i] <= 35 && p_q[i] >= 19) { q19++; } if (p_q[i] <= 60 && p_q[i] >= 36) { q36++; } if (p_q[i] >= 61) { q61++; } } printf("%0.2f%\n", q0 / n * 100); printf("%0.2f%\n", q19 / n * 100); printf("%0.2f%\n", q36 / n * 100); printf("%0.2f%%", q61 / n * 100); return 0; }
- 1
信息
- ID
- 1006
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 480
- 已通过
- 189
- 上传者