输入
ab cd efgh
输出
efgh
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
char s[110];
while(gets(s))
{
int l=strlen(s),coun,low,high,i;
int high_position=-1,low_position;
int maxn=-1;
for(int i=high_position+1; i<l; i++)
{
coun=0;
low_position=i;//记录起始位置
while(s[i]!=' '&&s[i]!='\0')
{
i++;
coun++;
}
high_position=i;//记录结束位置
if(coun>maxn)
{
maxn=coun;
low=low_position;
high=high_position;
}
}
for(i=low; i<high; i++)
printf("%c",s[i]);
printf("\n");
}
}