3 条题解
-
1
#include <bits/stdc++.h> using namespace std; int main() { int x[1000],n,i,a=0,b=0,c=0,d=0; cin>>n; for(i=0;i<n;i++) { cin>>x[i]; if(x[i]<=18) { a++; }else if(x[i]<=35) { b++; }else if(x[i]<=60) { c++; }else { d++; } } cout<<a<<" "<<fixed<<setprecision(2)<<a100.0/n<<"%"<<endl; cout<<b<<" "<<fixed<<setprecision(2)<<b100.0/n<<"%"<<endl; cout<<c<<" "<<fixed<<setprecision(2)<<c100.0/n<<"%"<<endl; cout<<d<<" "<<fixed<<setprecision(2)<<d100.0/n<<"%"<<endl; return 0; }
-
-1
#include <bits/stdc++.h> using namespace std; int main(){ int arr[1000],n,i,a = 0,b = 0,c = 0,d = 0; cin>>n; for(i = 0;i < n;i++){ cin>>arr[i]; if(arr[i] <= 18){ a++; }else if(arr[i] <= 35){ b++; }else if(arr[i] <= 60){ c++; }else{ d++; } } cout<<a<<" "<<fixed<<setprecision(2)<<a*100.0/n<<"%"<<endl; cout<<b<<" "<<fixed<<setprecision(2)<<b*100.0/n<<"%"<<endl; cout<<c<<" "<<fixed<<setprecision(2)<<c*100.0/n<<"%"<<endl; cout<<d<<" "<<fixed<<setprecision(2)<<d*100.0/n<<"%"<<endl; }
-
-1
#include<stdio.h>
#include
using namespace std;
int main() {
int n,x,i,a,b,c,d;
double sum;
while(scanf("%d",&n)!=EOF)
{
a=0; b=0; c=0; d=0; for(i=0;i<n;i++)
{
scanf("%d",&x);
if(x<=18) a++;
if(x>=19&&x<=35)
b++;
if(x>=36&&x<=60)
c++;
if(x>=61)
d++;
}
sum=a+b+c+d;
cout<<a<<" ";
printf("%.2lf%%\n",a*(100/sum));
cout<<b<<" ";
printf("%.2lf%%\n",b*(100/sum));
cout<<c<<" ";
printf("%.2lf%%\n",c*(100/sum));
cout<<d<<" ";
printf("%.2lf%%\n",d*(100/sum)); }
return 0; }
- 1
信息
- ID
- 423
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 5
- 标签
- 递交数
- 20
- 已通过
- 14
- 上传者