Problem Description
Enter n strings (n<=100) to output the longest string, and if there are multiple, take the first one found.
Input
Multiple sets of test data. The first row of each set of test data contains an integer n, representing a total of n strings. Next, each line contains a string that consists of printable characters.
Output
Each set of test sample output one row. The output finds a string that satisfies the test instructions.
Sample Input
3djdlkfjsadfjwedlkfjdlkfjl;jf;sfjdsl;al/dljfd2dlkasfjmmlld;femflsad;fiwejdif
Sample Output
Dlkfjdlkfjl;jf;sfjdsl;al/ld;femflsad;fiwejdif
1#include <stdio.h>2#include <string.h>3 intMain ()4 {5 intn,i;6 Chara[101],b[101],ch;7 while(SCANF ("%d", &n)! =EOF)8 {9 while((Ch=getchar ())! ='\ n');Ten gets (a); One for(i=1; i<n;i++) A { - gets (b); - if(Strlen (a) <strlen (b)) the strcpy (A, b); - } - puts (a); - } + - return 1; +}
Wuhan University of Science and Technology acm:1006: Chinese Edition C language Programming tutorial (second edition) Exercise 7.15