2 条题解

  • 0
    @ 2023-11-3 20:01:19

    呵呵

    #include <bits/stdc++.h>
    using namespace std;
    int n, ans, x, y, a[105];
    bool cmp(int x, int y)
    {
        return x > y;
    }
    int main()
    {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        cin >> x >> y;
        sort (a + 1, a + n + 1, cmp);
        for (int i = 1; i <= n; i++)
        {
            if (a[i] >= x && a[i] <= y)
            {
                cout << a[i] << " ";
                ans++;
            }
        }
        cout << endl;
        cout << ans << endl;
        return 0;
    }
    
    • 0
      @ 2023-1-22 11:14:08
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n,a[105],x,y,num=0;
          cin >> n;
          for(int i=1;i<=n;i++)
          {
              cin >> a[i];
          }
          cin >> x >> y;
          sort(a+1,a+n+1);
          for(int i=n;i>=1;i--)
          {
              if(a[i]>=x&&a[i]<=y)
              {
                  cout << a[i] << " ";
                  num++;
              }
          }
          cout << endl << num;
      }
      
      • 1

      信息

      ID
      1079
      时间
      1000ms
      内存
      128MiB
      难度
      4
      标签
      递交数
      18
      已通过
      17
      上传者