源代码:
#include <stdio.h>
int main(void)
{
int n; scanf("%d", &n), getchar();
static char str_1[100 + 1], str_2[100 + 1];
int max = 1, max_length = 0, temp_length = 0;
char* max_p = str_1, * temp_p = str_2,
* max_c_p = max_p, * temp_c_p = temp_p;
while ((*max_c_p = getchar()) != '\n') max_c_p++; *max_c_p = '\0';
max_length = max_c_p - max_p;
for (int i = 2; i <= n; i++)
{
for (temp_c_p = temp_p; (*temp_c_p = getchar()) != '\n'; temp_c_p++)
{
if (max_p[temp_c_p - temp_p] != *temp_c_p)
{
int flag = max_p[temp_c_p - temp_p] < *temp_c_p;
while ((*++temp_c_p = getchar()) != '\n'); *temp_c_p = '\0';
temp_length = temp_c_p - temp_p;
if (flag && max_length <= temp_length || max_length < temp_length)
{
max = i, max_length = temp_length;
char* swap = max_p; max_p = temp_p; temp_p = swap;
}
break;
}
}
}
printf("%d\n%s", max, max_p);
return 0;
}