RT,我利用字符串长度(水)到了60分,接下来该怎么写?
  • 板块P1781 宇宙总统
  • 楼主expnoi
  • 当前回复3
  • 已保存回复3
  • 发布时间2020/9/29 21:00
  • 上次更新2023/11/5 12:25:06
查看原帖
RT,我利用字符串长度(水)到了60分,接下来该怎么写?
378346
expnoi楼主2020/9/29 21:00
#include<bits/stdc++.h>
using namespace std;
struct node{
	int id,length;
}len[1001];
int cmp(node x,node y)
{
	return x.length>y.length;
}
int main()
{
	ios::sync_with_stdio(false);
	int i,n;
	char a[21][1001];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		len[i].length=strlen(a[i]);
		len[i].id=i;
	}
	sort(len,len+n,cmp);
	cout<<len[0].id+1<<"\n"<<a[len[0].id]<<"\n";
}
2020/9/29 21:00
加载中...