- 题目
- 输入样例
Keywords insert, two way insertion sort,
Abstract This paper discusses three method for two way insertion
words. insert, two way sorted.
You're a boy.
题目是多组数据,找到单组数据最长单词的函数已经写出来了,但不知道怎么结束程序,早些时候有个老哥用别的平台写了一段代码,但是看不太懂,希望能帮我重写主函数部分。
- 我写的代码
void find(char b[81])
{
int i;
int o;
int p;
int count = 0;
int length = 0;
int start = 0;
int m;
int maxlength = 0;
int dot = 0;
for (o = 0; b[o] != '\0'; o++)
{
if (b[o] == ' ')
start = o + 1;
if (o == start)
{
m = o;
while ((b[o] >= 'A' && b[o] <= 'Z') || (b[o] >= 'a' && b[o] <= 'z'))
{
o++;
length++;
}
if (maxlength < length)
{
maxlength = length;
dot = start;
}
length = 0;
o = m;
}
if (b[o + 1] == '\0')
{
for (i = dot; ((b[i] >= 'A' && b[i] <= 'Z') || (b[i] >= 'a' && b[i] <= 'z')); i++)
{
printf("%c", b[i]);
}
printf("\n");
}
}
}
int main()
{
char a[100];
while(gets(a))
{
find(a);
}
return 0;
}
- 运行效果