建议把高精度去掉
查看原帖
建议把高精度去掉
1399241
GAOchang12楼主2024/8/8 12:10

这道题用sort就可以做

#include <bits/stdc++.h>
using namespace std;
struct sss{
	string a;
	int t,m;
} s[21];
bool cmp(sss x,sss y){
	if(x.m!=y.m) return x.m>y.m;
	return x.a>y.a;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i].a;
		s[i].t=i;
		s[i].m=s[i].a.size();
	}
	sort(s+1,s+n+1,cmp);
	cout<<s[1].t<<endl<<s[1].a;
	return 0;
}
2024/8/8 12:10
加载中...