公共字串計算

2021-07-04 21:22:31 字數 754 閱讀 4911

述計算兩個字串的最大公共字串的長度,字元不區分大小寫

詳細描述:

介面說明

原型:int getcommonstrlength(char * pfirststr, char * psecondstr);

輸入引數:

char * pfirststr //第乙個字串

char * psecondstr//第二個字串

知識點字串,查詢

執行時間限制

10m記憶體限制

128輸入

輸入兩個字串

輸出輸出乙個整數

樣例輸入

asdfas werasdfaswer

樣例輸出

6 二、個人ac掉的**

#include #include #include #include #include #include #include #include using namespace std;

//kmp方法中的next表

void getnext(string needle,vector&next)

{ next[0]=-1;

int i=0,k=-1,size=needle.size();

while(inext(nsize,0);

//獲取next表

getnext(needle,next);

//求最大公共字串長度

while(i>haystack;

cin>>needle;

cout<

公共字串計算

計算兩個字串的最大公共字串的長度,字元不區分大小寫 介面說明 原型 int getcommonstrlength char pfirststr,char psecondstr 輸入引數 char pfirststr 第乙個字串 char psecondstr 第二個字串 知識點 字串,查詢 輸入 字...

公共字串計算

公共字串計算 計算兩個字串的最大公共字串的長度,字元不區分大小寫 詳細描述 介面說明 原型 int getcommonstrlength char pfirststr,char psecondstr 輸入引數 char pfirststr 第乙個字串 char psecondstr 第二個字串 求最...

牛客網 公共字串計算

題目描述 詳細描述 介面說明 原型 int getcommonstrlength char pfirststr,char psecondstr 輸入引數 char pfirststr 第乙個字串 char psecondstr 第二個字串輸入描述 輸入兩個字串 輸出描述 輸出乙個整數 示例1輸入 輸...