2 solutions

  • 0
    @ 2025-2-5 13:09:07
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int a1,a2,p1,p2;
        cin>>a1>>p1;
        cin>>a2>>p2;
        if(a1>a2){
            cout << "\"";
            cout << "\\"<<"n";
            cout << "\"";
        }else if(a1==a2){
            if(p1<p2){
                cout << "\"";
                cout << "\\"<<"n";
                cout << "\"";
            }
            else if(p1>p2){
                cout << "\"";
                cout << "\\"<<"t";
                cout << "\"";
            }
        }else{
            cout << "\"";
            cout << "\\"<<"t";
            cout << "\"";
        }
        return 0;
    }
    

    就是写几个判断。

    希望有大佬能帮忙写一下结构体的代码。 半成品:

    #include <bits/stdc++.h>
    #include <algorithm>
    using namespace std;
    struct stu{
        int A,P,num;
    }win[10];
    bool cmp(stu a,stu b){
        if(a.A==b.A){
            return a.P<b.P;
        }return a.A>b.A;
    }
    int main(){
        for(int i=1;i<=2;i++){
            cin>>win[i].a>>win[i].p;
            win[i].num=i;
        }
        sort(win+1,win+1+2,cmp);
        
        return 0;
    }
    

    image

    • 0
      @ 2024-12-10 17:29:42
      using namespace std; 
      int main()
      {
      	int a,b,c,d; 
      	cin>>a>>b>>c>>d; 
      	if(a>c) 
      	{
      		cout << "\"";
      		cout<<"\\"<<"n";
      		cout << "\"";
      	
      	}
      	else if(b>d) 
      	{
      		cout << "\"";
      		cout <<"\\"<< "t";
      		cout << "\"";	
      	}
      	else if(b<d)
      	{
      		cout << "\"";
      		cout<<"\\"<<"n";
      		cout << "\"";
      	}
      	else
      	{
      		cout << "\"";
      		cout <<"\\"<< "t";
       		cout << "\"";
      	}
      return 0; 
      }
      
      • 1

      Information

      ID
      690
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      7
      Tags
      (None)
      # Submissions
      155
      Accepted
      33
      Uploaded By