Codeforce Problem 711A - Bus to Udayland (正则表达式)

https://codeforces.com/problemset/problem/711/A

正则表达式基本应用

#include
using namespace std;
int n, i;
string s, t;
int main() {
	//freopen("in.txt", "r", stdin);
	cin >> n; while (n--)cin >> s, t += s + "\n";//将字符累加到一个大字符串中
	i = t.find("OO");//也可以用match替换
	if (i >= 0)t.replace(i, 2, "++"), cout << "YES" << endl << t;
	else cout << "NO";
	return 0;
}

你可能感兴趣的:(Codeforce Problem 711A - Bus to Udayland (正则表达式))