ACM寒假集训2019.1.28

题目链接:https://vjudge.net/contest/279650#problem/A

思路简析:
从输入项中找出最先两个相邻的“O”,如不存在,直接输出“NO”结束;
若存在,则先把两个“O”改成两个“+”,再输出“YES”,然后输出修
改后的字符组。

代码:

#include 
using namespace std;
int main()
{
	int i, n;
	cin >> n;
	if (n < 1 || n>1000)
		return 0;
	char (*a)[6] = new char[n][6];
	for (i = 0; i < n; i++)
		for (int j = 0; j < 5; j++)
			cin >> a[i][j];
	for (i = 0; i < n; i++)
	{
		if (a[i][0] =='O'&& a[i][1]=='O')
		{
			a[i][0] = '+';
			a[i][1] = '+';
			cout << "YES" << endl;
			break;
		}
		if (a[i][3] == 'O'&& a[i][4] == 'O')
		{
			a[i][3] = '+';
			a[i][4] = '+';
			cout << "YES"<

你可能感兴趣的:(ACM寒假集训2019.1.28)