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

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

正则表达式基本应用

#include<bits/stdc++.h>
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;
}
posted @ 2020-08-01 11:49  RioTian  阅读(175)  评论(0编辑  收藏  举报