怎么会WA呢?
查看原帖
怎么会WA呢?
957640
Michelle01楼主2023/8/1 15:55
#include <stdio.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;


struct node{
	
	int ans = 0;
	string in;
	
}a[200];

struct node1{
	string in1;
	
}b[200];

bool cmp(node x, node y){
	return x.ans > y.ans;
}

int main() {
	
	int i = 1, j = 1; 
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i].in;
		b[i].in1 = a[i].in; 
	}
	while(n * n--){
		if(a[j].in == b[i].in1){
			a[j].ans++;
		}
		i++;
		if(i <= n){
			j++;
			i = 1;
		}
	}
	sort(a + 1, a + n + 1, cmp);
	cout << a[1].in;

	return 0;
}
2023/8/1 15:55
加载中...