当前位置:网站首页>Longest word in output string

Longest word in output string

2022-06-22 23:21:00 holoyh

#include<Stdio.h>
 
int main()
{
	char str[80] = "this  isndnsjfida  is a pencil   good   ";
	char *p,*s = str;
	int num=0,max = 0;
	
	while(*s)
	{
		while(*s&&(*s>='a'&&*s<='z'||*s>='A'&&*s<='Z'))
		{
			num++;
			s++;
		}
		if(num > max)
		{
			max = num;
			p = s;
		}
		num = 0;
		
		while(*s&&*s==' ')
		{
			s++;
		}
	}
	*p = 0;
	puts(p-max);
}

pencil

原网站

版权声明
本文为[holoyh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206222056169353.html