本人蒟蒻,20分wa了,求大佬看看为啥
查看原帖
本人蒟蒻,20分wa了,求大佬看看为啥
1412841
BaiBaiShaFeng楼主2024/10/2 19:11

代码↓

#include <bits/stdc++.h>
using namespace std;

struct man{
	int votes;
	int numb;
};

bool cmp(man a, man b){
	return a.votes>b.votes;
}

int main(){
	int n;
	scanf("%d", &n);
	man pr[n];
	for(int i=1; i<=n; i++){
		pr[i-1].numb=i;
		scanf("%d",&pr[i-1].votes);
	}
	sort(pr, pr+n, cmp);
	cout<<pr[0].numb<<endl<<pr[0].votes;
	return 0;
}

不知道为啥

2024/10/2 19:11
加载中...