3105. 最长单词

Medium函数字符串普通指针

时间限制:2000 ms

内存限制:256 MiB

题面

定义函数 LongestWord 找出一个字符串中最左边的最长单词。

单词之间用一个空格或多个空格分隔。

提示

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/
#include <stdio.h>

//********** Specification of LongestWord **********
void LongestWord(const char str[],char result[])
/* PreCondition:
   str is a string with length no more than 80
   PostCondition:
   find the first longest word in str, and put it in result.
   changing str is not allowed
*/
{ //TODO: your function definition
}

/***************************************************************/
#define N 80
int main()
{   char s[N+1],r[N+1];
	gets(s);
//********** LongestWord is called here ************
	LongestWord(s,r);
//**************************************************
	printf("%s\n",r);
	return 0;
}