标签:line you \n col ant display 分析 bst osi
3 11 1001110110 101 110010010010001 1010 110100010101011
3 0 3
/** 题目大意: 求一个串的子串,再判断该串与题目所给的串是否相同 分析: 通过C++提供的substr函数求子串 substr用法:str2 = str1.substr (index, length) **/
C/C++代码实现:
#include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <cstdio> #include <stack> using namespace std; int N, len1, len2, cnt; string s1, s2, s3; int main () { scanf ("%d", &N); while (N --) { cnt = 0; cin >>s1 >>s2; len1 = s1.size(); len2 = s2.size(); for (int i = 0; i < len2 - len1 + 1; ++ i) { s3 = s2.substr(i, len1); if (s1 == s3) ++ cnt; } printf ("%d\n", cnt); } return 0; }
标签:line you \n col ant display 分析 bst osi
原文地址:https://www.cnblogs.com/GetcharZp/p/8929098.html