4 条题解

  • 1
    @ 2024-7-23 13:40:30

    #include<bits/stdc++.h> using namespace std; struct student{ int ch[1001]; string name[1001]; }a;

    int main(){ int n,max=0; cin>>n; for(int i=1;i<=n;i++){ cin>>a.ch[i]>>a.name[i]; if(a.ch[i]>max){ max=a.ch[i]; } } for(int i=1;i<=n;i++){ if(max==a.ch[i]) cout<<a.name[i]; } return 0; }

    • 1
      @ 2024-7-23 13:39:26

      #include<bits/stdc++.h> using namespace std; struct stu{ int score; string name; }a[105],ans; int main(){ int n; cin>>n; ans.score=0; for(int i=1;i<=n;i++){ cin>>a[i].score>>a[i].name; if(a[i].score>ans.score){ ans = a[i]; } } cout<<ans.name; return 0; }

      • 1
        @ 2024-7-23 11:44:20
        #include <iostream>
        #include <string>
        using namespace std;
        
        int main()
        {
        	int N;
        	cin >> N;
        	
        	int score = 0;
        	string name = "";
        	
        	int max_score = 0; // 最高分;
        	string ans = "";
        	
        	for (int i = 0; i < N; i++)
        	{
        		cin >> score >> name;
        		if (score > max_score)
        		{
        			max_score = score; // 更新最高分;
        			ans = name;
        		}
        	}
        	cout << ans << endl;
            return 0;
        }
        
        • 0
          @ 2024-7-23 13:39:43
          #include<bits/stdc++.h>
          using namespace std;
          int n;
          struct s{
          	int score;
          	string name;
          }a[101],ans;
          int main(){
          	cin>>n;
          	ans.score=0;
          	for(int i=1;i<=n;i++){
          		cin>>a[i].score>>a[i].name;
          		if(a[i].score>=ans.score)ans=a[i];
          	}
              cout<<ans.name;
              return 0;
          }
          

          高级点的

          • 1

          信息

          ID
          1312
          时间
          1000ms
          内存
          128MiB
          难度
          3
          标签
          (无)
          递交数
          185
          已通过
          103
          上传者