HPU 1064 Find the longest name

1064: name introduction  [string]


Topic description

Walking into the campus, Yang Bafang was intoxicated by the university atmosphere. The water of Xinyue Lake reflects the sunlight, and bursts of new students bring new vitality, which makes people feel relaxed and happy.

After completing the relevant procedures at the freshman registration office, students from Bafang came to the dormitory. After registering with the dormitory aunt, Bafang came to the room where he will live in the future. Entering the door, I saw that some friends have arrived at the dormitory.

After a few chats (tens of thousands of words are omitted here...), Bafang couldn't help but sigh that the names of young people nowadays are really strange.

After that, Yang Bafang added the class's QQ group. In order to get to know the classmates as soon as possible, Yang Bafang looked through the group members' notes and saw at a glance that someone's name was particularly long...

So the question is, if all the names are expressed in pinyin, can you quickly find the longest one?

enter

The first line is an integer nn ( 0<n<1000<n<100  ), representing nn classmates.

below nEach of the n lines has a string containing only lowercase letters (the length does not exceed 20), representing the name of the classmate.

Guaranteed to have only one longest name.

output

Output the longest name.

sample input

4
zhenqiguai
yangqifang
yangbafang
yangjiufang

Sample output

yangjiufang


Compilation fails:

#include<iostream>

#include<cstring>
using namespace std;
int main()
{
int n,i,maxn;//maxn保存长度,l保存最长字符 
char str[105],l;
cin>>n;
getchar();
for(i=0;i<n;i++)
{
cin>>str[i];
}
        maxn=strlen(str[0]);
        for(i=0;i<n;i++)
        {
            if(strlen(str[i])>maxn)
            {
            maxn=strlen(str[i]);
                strcpy(l,str[i]);
}
        }
        cout<<l;
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324593130&siteId=291194637