2 条题解

  • 1
    @ 2023-2-3 20:18:53
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        double n;
        int e[104],a=0,b=0,c=0,d=0;
        cin >> n;
        for(int i=1;i<=n;i++)
        {
            cin >> e[i];
            if(e[i]>60)
            {
                d++;
            }
            else if(e[i]>35)
            {
                c++;
            }
            else if(e[i]>18)
            {
                b++;
            }
            else
            {
                a++;
            }
        }
        cout << a << " " << fixed << setprecision(2) << a/n*100;
        cout << "%" << endl;
        cout << b << " " << fixed << setprecision(2) << b/n*100;
        cout << "%" << endl;
        cout << c << " " << fixed << setprecision(2) << c/n*100;
        cout << "%" << endl;
        cout << d << " " << fixed << setprecision(2) << d/n*100;
        cout << "%" << endl;
    }
    
    • 0
      @ 2023-10-28 21:57:26
      #include <cstdio>
      using namespace std;
      int main(){
          int a=0,b=0,c=0,d=0,n,x;
          scanf("%d",&n);
          for(int i=1;i<=n;i++){
              scanf("%d",&x);
              if(0<=x&&x<=18)a++;
              else if(19<=x&&x<=35)b++;
              else if(36<=x&&x<=60)c++;
              else d++;
          }
          printf("%d %.2lf%%\n%d %.2lf%%\n%d %.2lf%%\n%d %.2lf%%\n",a,100.0*a/n,b,100.0*b/n,c,100.0*c/n,d,100.0*d/n);
          return 0;
      }
      
      • 1

      信息

      ID
      423
      时间
      1000ms
      内存
      16MiB
      难度
      1
      标签
      递交数
      36
      已通过
      31
      上传者