请大佬看看蒟蒻为什么错
查看原帖
请大佬看看蒟蒻为什么错
574849
biyi_mouse楼主2022/2/17 10:26
#include<iostream>
#include<cstdio>
using namespace std;
const int N = 100;
char a[N][N];
int n, m, x, y, flag;
char op;
int main() {
	cin >> n >> m;
	cin >> op;
	for (int i = 1; i <= n; i++)
			cin >> a[i];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (a[i][j] == 'o') x = i, y = j, flag = 1;
	if (!flag) {
		cout << "OK";
		return 0;
	}
	if (op == '^') {
		while (x <= n && x >= 1 && y <= m && y >= 1) {
			if (a[x][y] == 'x') {
				cout << "GG";
				return 0;
			}
			x--;
		}
	}
	if (op == 'v') {
		while (x <= n && x >= 1 && y <= m && y >= 1) {
			if (a[x][y] == 'x') {
				cout << "GG";
				return 0;
			}
			x++;
		}
	}
	if (op == '>') {
		while (x <= n && x >= 1 && y <= m && y >= 1) {
			if (a[x][y] == 'x') {
				cout << "GG";
				return 0;
			}
		}
	}
	if (op == '<') {
		while (x <= n && x >= 1 && y <= m && y >= 1) {
			if (a[x][y] == 'x') {
				cout << "GG";
				return 0;
			}
		}
	}
	cout << "OK";
	return 0;
}
2022/2/17 10:26
加载中...