其他分享
首页 > 其他分享> > 1106:年龄与疾病

1106:年龄与疾病

作者:互联网

 

 

#include<cstdio>
int a[120];
int main()
{
    int x;
    scanf("%d",&x);
    double s1=0,s2=0,s3=0,s4=0;
    for(int i=0;i<x;++i)
    {
        scanf("%d",&a[i]);
        if(a[i]<=18)
        s1++;
        
        else if(a[i]<=35)
        s2++;
        
        else if(a[i]<=60)
        s3++;
        
        else if(a[i]>=61)
        s4++;
    }
    double f1,f2,f3,f4;
    f1=s1/x*100;
    f2=s2/x*100;
    f3=s3/x*100;
    f4=s4/x*100;
    printf("%.2lf%%\n",f1);
    printf("%.2lf%%\n",f2);
    printf("%.2lf%%\n",f3);
    printf("%.2lf%%\n",f4);
    return 0;
 }

 

标签:f1,%.,int,1106,printf,100,2lf%,年龄,疾病
来源: https://www.cnblogs.com/zheng1945/p/16298511.html