top1编程
← 返回题目
题解

【入门】象棋比赛

3 条题解

  • 0
    @ 2026-7-29 20:23:46
    #include <bits/stdc++.h>
    using namespace std;
    
    int main () {
    	int n, c1 = 0, c2 = 0;
    	cin >> n;
    	while (n--) {
    		int t;
    		cin >> t;
    		if (t == 10) {
    			c1++;
    		} else {
    			c2++;
    		}
    	}
    	if (c1 > c2) {
    		cout << 10;
    	} else {
    		cout << 20;
    	}
    	
    }
    
    • 0
      @ 2026-7-29 0:06:24
      #include <bits/stdc++.h>
      using namespace std;
      
      int main () {
      	int n, c1 = 0, c2 = 0;
      	cin >> n;
      	while (n--) {
      		int t;
      		cin >> t;
      		if (t == 10) {
      			c1++;
      		} else {
      			c2++;
      		}
      	}
      	if (c1 > c2) {
      		cout << 10;
      	} else {
      		cout << 20;
      	}
      	
      }
      
      • 0
        @ 2026-7-28 22:09:56
        #include<iostream>
        using namespace std;
        int main()
        {
            int n;
            int a[100];
            cin>>n;
            for(int i=1;i<=n;i++){
                cin>>a[i];
            }
            int c1=0;
            int c2=0;
            for(int i=1;i<=n;i++){
                if(a[i]==10){
                    c1++;
                }else{
                    c2++;
                }
            }
            if(c1>c2){
                cout<<10;
            }else{
                cout<<20;
            }
            return 0;
        }
        
        • 1