版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/y895315416/article/details/78958396
/*
求出5个字符串中最长的字符串。每个字符串长度在100以内,且全为小写字母。
样例输入
one two three four five
样例输出
three
*/
#include<stdio.h>
#include<string.h>
int main(void)
{
char s[5][100] ;
int c[5];
int i,t,max = 0 ;
for( i = 0 ; i < 5 ; i ++ )
{
scanf("%s",s[i]);
c[i] = strlen(s[i]);
if( c[i] > max)
{
max = c[i];
t = i ;
}
}
puts(s[t]);
return 0;
}
求出5个字符串中最长的字符串。每个字符串长度在100以内,且全为小写字母。
样例输入
one two three four five
样例输出
three
*/
#include<stdio.h>
#include<string.h>
int main(void)
{
char s[5][100] ;
int c[5];
int i,t,max = 0 ;
for( i = 0 ; i < 5 ; i ++ )
{
scanf("%s",s[i]);
c[i] = strlen(s[i]);
if( c[i] > max)
{
max = c[i];
t = i ;
}
}
puts(s[t]);
return 0;
}