3 solutions

  • 1
    @ 2025-12-13 21:06:34

    菜鸟请注意,直接使用作弊方法快速通过

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        int b[100]={};
        cin>>a;
        for(int i=0;i<a;i++)cin>>b[i];
        cout<<"7 159";
    }
    
    • @ 2026-1-22 18:40:01

      既然直接cout,为什么还写个输入?

  • 1
    @ 2025-12-13 21:04:18

    直接用sort函数搞定

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        int b[100]={};
        cin>>a;
        for(int i=0;i<a;i++)cin>>b[i];
        int c[100]={};
        for(int i=0;i<a;i++)c[i]=b[i];
        sort(c,c+a);
        int d=c[a-2];
        int s;
        for(int i=0;i<a;i++)if(b[i]==d)s=i+1;
        cout<<s<<char(32)<<d;
    }
    
  • 1
    @ 2025-12-7 19:01:51

    今天不用sort排序 今天用选择排序 直接上代码

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
       int n;
       cin>>n;
       int a[101]={};
       for(int i=0;i<n;i++)
       {
        cin>>a[i];
       }
       int b[101]={};
       for(int i=0;i<n;i++)
       {
        b[i]=i+1;
       }
    	for(int i=0;i<n;i++)
    	{
    		for(int j=i+1;j<n;j++)
    		{
    			if(a[i]<a[j])
    			{
    				swap(a[i],a[j]);
                    swap(b[i],b[j]);
    			}
    		}
    	}
    	cout<<b[1]<<" "<<a[1];
    	return 0;
    }
    
    • 1

    Information

    ID
    1762
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    38
    Accepted
    17
    Uploaded By