华为OJ

ID:2011 

公共字串计算       
描述: 

题目标题:

计算两个字符串的最大公共字串的长度,字符不区分大小写

详细描述:

接口说明

原型:

int getCommonStrLength(char * pFirstStr, char * pSecondStr);

输入参数:

     char * pFirstStr //第一个字符串

     char * pSecondStr//第二个字符串

 

 
知识点:  字符串,查找 
题目来源:  内部整理 
练习阶段:  初级 
运行时间限制: 10Sec
内存限制: 128MByte
输入:  

输入两个字符串

 
输出:  

输出一个整数

 
样例输入:
asdfas werasdfaswer
                   
样例输出:
6
                    


[code=c]#include 
#include 
#include 

using namespace std;

int getCommonStrLength(char * pFirstStr, char * pSecondStr)
{
	int len1 = strlen(pFirstStr);
	int len2 = strlen(pSecondStr);
	int i;
	int maxValue = 0;
	char *Fstr,*Sstr;
	int len = len1<=len2 ? len1 : len2;
	if(len == len1)
	{
		Fstr = (char *)malloc(sizeof(char)*(len1+1));
		Sstr = (char *)malloc(sizeof(char)*(len2+1));
		for ( i=0;i>s1>>s2;
//	cout<<"s1:"<


你可能感兴趣的:(华为OJ)