3 条题解

  • 2
    @ 2023-10-6 16:44:38

    成功AC此题

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        int n, a[1005],maxn1=-1,maxn2=-1;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            if(a[i]%2==1) maxn1=max(maxn1,a[i]);
            else maxn2=max(maxn2,a[i]);
        }
        cout<<maxn1<<" "<<maxn2<<endl;
        sort(a+1,a+n+1);
        for(int i=1;i<=n;i++) cout<<a[i]<<" ";
        return 0;
    }
    
    • 2
      @ 2023-1-29 13:31:50
      #include <bits/stdc++.h>
      using namespace std;
      int n,a[1005],max1,max2;
      int main()
      {
          cin >> n;
          for(int i=1;i<=n;i++)
          {
              cin >> a[i];
              if(a[i]%2==0)
              {
                  if(a[i]>max2)
                  {
                      max2=a[i];
                  }
              }
              else
              {
                  if(a[i]>max1)
                  {
                      max1=a[i];
                  }
              }
          }
          sort(a+1,a+n+1);
          cout << max1 << " " << max2 << endl;
          for(int i=1;i<=n;i++)
          {
              cout << a[i] << " ";
          }
      }
      
      • 1
        @ 2024-5-1 21:03:34

        也是非常简单好吧,直接AC,放心品尝

        #include <bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n, a[1005], maxj = 0, maxo = 0;
            cin >> n;
            for (int i = 1; i <= n; i++)
            {
                cin >> a[i];
                if (a[i] > maxj && a[i] % 2 == 1)
                {
                    maxj = a[i];
                }
                if (a[i] > maxo && a[i] % 2 == 0)
                {
                    maxo = a[i];
                }
            }
            cout << maxj << " " << maxo << endl;
            sort (a + 1, a + n + 1);
            for (int i = 1; i <= n; i++)
            {
                cout << a[i] << " ";
            }
            return 0;
        }
        
        • 1

        信息

        ID
        720
        时间
        1000ms
        内存
        128MiB
        难度
        1
        标签
        递交数
        52
        已通过
        41
        上传者