1808:最长字符串
算法训练 最长字符串
时间限制:1.0S 内存限制:512.0MB
求出5个字符串中最长的字符串。每个字符串长度在100以内,且全为小写字母。
样例输入
one two three four five
样例输出
three
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
char ch[5][101];
int i,max ;
int n[5];
for(i=0;i<5;i++)
{
scanf("%s",ch[i]);
n[i]=strlen(ch[i]);
}
max=0 ;
for(i=1;i<5;i++)
{
if(n[max]<n[i])
{
max=i ;
}
}
cout<<ch[max];
return 0;
}