解题思路:
可以用两个数组a,b,因为%s是不收取空格,用while循环每次获取一段,然后对比

当然也可以用二维数组
注意事项:

参考代码:

#include<stdio.h>
#include<string.h>
int main()
{
	char a[501],b[501];
	int len=0,max=0;
	while(scanf("%s",b)!=EOF)
	{
	    len=strlen(b);
	    if(b[len-1]=='.')//如果这段字符串有点就赋空
	    b[len-1]='\0';
	    if(len>max)
	    {
	        max=len;
	        strcpy(a,b);//b字符串复制给a,由于每次复制给a的字符串,都会比a当前的字符串长,不用担心会有上一个字符串残留问题
	    }
	}
	puts(a);
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区