1808:最长字符串

来源:互联网 发布:centos 搜索文件内容 编辑:程序博客网 时间:2024/06/06 08:54

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;}


原创粉丝点击