// 100_46.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int find_len(char * str)
{
	if(str==NULL)
		return 0;
	int len = 1;
	char * cur = str;
	while(*str!='\0')
	{
		char * left = cur-1;
		char * right = cur+1;
		while(left>=str && *right!='\0' && *left==*right)
		{
			left--;
			right++;
		}
		int new_len = right-left+1;
		if(new_len > len)
			len = new_len;

		left = cur-1;
		right = cur+1;
		while(left>=str && *right!='\0' && *left==*right)
		{
			left--;
			right++;
		}
		new_len = right-left+1;
		if(new_len > len)
			len = new_len;

		str++;
	}
	return len;
}

int _tmain(int argc, _TCHAR* argv[])
{
	char str[] = "google";
	printf("%d\n",find_len(str));
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-02-12
  • 2023-02-05
  • 2021-09-23
  • 2022-12-23
  • 2021-12-22
  • 2021-12-30
猜你喜欢
  • 2021-06-06
  • 2021-09-30
  • 2022-02-19
  • 2022-12-23
  • 2021-12-21
  • 2021-06-18
  • 2022-01-05
相关资源
相似解决方案