提交时间:2019-12-08 21:23:28
运行 ID: 2961
#include<iostream> using namespace std; int main(){ int a[101],n; double c1=0,c2=0,c3=0,c4=0; // c1-c4表示四个年龄段得病人数。 cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]>=0 && a[i]<=18) c1++; if(a[i]>=19 && a[i]<=35) c2++; if(a[i]>=36 && a[i]<=60) c3++; if(a[i]>=61) c4++; } printf("%.2lf%%\n", (c1/n)*100); printf("%.2lf%%\n", (c2/n)*100); printf("%.2lf%%\n", (c3/n)*100); printf("%.2lf%%\n", (c4/n)*100); return 0; }