Educational Codeforces Round 144 (Rated for Div. 2)题解

A.Typical Interview Problem

利用好c++当中的 stl,刚开始为了匹配两个字符串,还自己手写了一个双指针,其实是没有必要的,在一个字符串当中找另一个字符串,我们可以使用find函数,但是这里和寻找单个字符不一样,如果是寻找单个字符的化,遍历整个字符串,find返回值不等于end,就说明存在

这里 稍微有点不一样,学会这个用法:

#include

using namespace std;

string S = "FBFFBFFBFBFFBFFBFB";
//FFB   
int main(){
	int t;
	cin >> t;
	while(t --){
		int n;
		cin >> n;
		string s;//FFB
		cin >> s;
		cout << (S.find(s) != string::npos ? "Yes" : "No") << endl;
		
	}
	return 0;
}

你可能感兴趣的:(算法,数据结构,c++)