Wuhan University of Science and Technology acm:1006: Chinese Edition C language Programming tutorial (second edition) Exercise 7.15

Source: Internet
Author: User
Tags printable characters

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.