5 条题解

  • 2
    //罕见的C程序题解
    #include<stdio.h>
    int main()
    {
        int n;
        int a[100];
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%d", &a[i]);
        double sum1 = 0,sum2 = 0,sum3=0,sum4=0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] >= 0 && a[i] <= 18)
                sum1++;
            else if (a[i] >= 19 && a[i] <= 35)
                sum2++;
            else if (a[i] >= 36 && a[i] <= 60)
                sum3++;
            else if (a[i] >= 61 )
                sum4++;
        }
        printf("%.2f%%\n%.2f%%\n%.2f%%\n%.2f%%\n", 100*sum1 / n, 100*sum2 / n, 100*sum3 / n, 100*sum4 / n);
    
        return 0;
    }
    
  • 1
    @ 2024-08-28 11:55:55
    #include<stdio.h>
    using namespace std;
    int cnt[4] = {0, 0, 0, 0}, n, q;
    int main(){
        scanf("%d", &n);
        for(int i = 1; i <= n; i++){
            scanf("%d", &q);
            if(q <= 18)cnt[0]++;
            else if(q >= 19 && q <= 35)cnt[1]++;
            else if(q >= 36 && q <= 60)cnt[2]++;
            else cnt[3]++;
        }
        for(int i = 0; i < 4; i++)printf("%.2f%%\n", float(cnt[i])/n*100);
        return 0;
    }
    
  • 1
    @ 2022-07-28 10:24:49

    嗨嗨嗨

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    int n,m,a,s1=0,s2=0,s3=0,s4=0;
    cin>>n;
    m=n;
    while(n--)
    {
    cin>>a;
    if(a>=61)
    s1++;
    else if(a>=36)
    s2++;
    else if(a>=19)
    s3++;
    else
    s4++;
    }
    printf("%.2lf%\n%.2lf%\n%.2lf%\n%.2lf%\n",100.0*s4/m,100.0*s3/m,100.0*s2/m,100.0*s1/m);

    return 0;
    }

  • 0
    @ 2024-11-15 18:46:13

    #include<stdio.h>
    int main()
    {
    int n;
    int a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
    double sum1 = 0,sum2 = 0,sum3=0,sum4=0;
    for (int i = 0; i < n; i++)
    {
    if (a[i] >= 0 && a[i] <= 18)
    sum1++;
    else if (a[i] >= 19 && a[i] <= 35)
    sum2++;
    else if (a[i] >= 36 && a[i] <= 60)
    sum3++;
    else if (a[i] >= 61 )
    sum4++;
    }
    printf("%.2f%%\n%.2f%%\n%.2f%%\n%.2f%%\n", 100*sum1 / n, 100*sum2 / n, 100*sum3 / n, 100*sum4 / n);

    return 0;
    }

  • 0
    @ 2022-07-31 15:41:48

    很好,很有精神!

  • 1

统计不同年龄段患者的比例

信息

ID
1060
难度
6
分类
(无)
标签
递交数
647
已通过
162
通过率
25%
被复制
7
上传者