60分求助
查看原帖
60分求助
1122756
GekhubWZF楼主2024/9/8 18:51
#include <bits/stdc++.h>
using namespace std;
int n;

struct node {
	int i;
	string v;
} a[25];

bool cmp(node x, node y) {
	if (x.v.size() == y.v.size()) {

		return x.v.size() < y.v.size();
	}
	return x.v.size() > y.v.size();
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].v;
		a[i].i = i;
	}
	sort(a, a + 1 + n, cmp);
	cout << a[0].i << endl << a[0].v;
	return 0;
}

2024/9/8 18:51
加载中...