输入
5
98765
12365
87954
1022356
985678
输出
4
1022356
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n, num;
char a[201], max[201] = " ";
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a;
if(strlen(max) < strlen(a) || strlen(max) == strlen(a) && strcmp(max, a) < 0)
{
strcpy(max, a);
num = i;
}
}
cout << num << endl;
cout << max;
return 0;
}
字符串操作:strcpy;strcmp
均包含于头文件中。
由于数字极大,故使用字符串。