题解 | 小红的夹吃棋

小红的夹吃棋

https://www.nowcoder.com/practice/94648fd37a644c76adb2adb29c2a3037

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

void solve()
{
	int t;
	cin >> t;
	while(t--)//遍历模拟 注意每次都要初始化用来判断的变量
	{
		char s[3][3];
		bool red=true,pur=true;
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++) cin >> s[i][j];
		}
		for(int i=0;i<3;i++)
		{
			if(s[i][0]=='*')
			{
				if(s[i][2]=='*'&&s[i][1]=='o') pur=false;
			}
			else if(s[i][0]=='o')
			{
				if(s[i][2]=='o'&&s[i][1]=='*') red=false;
			}
		}
		for(int j=0;j<3;j++)
		{
			if(s[0][j]=='*')
			{
				if(s[2][j]=='*'&&s[1][j]=='o') pur=false;
			}
			else if(s[0][j]=='o')
			{
				if(s[2][j]=='o'&&s[1][j]=='*') red=false;
			}
		}
		if(red&pur) cout << "draw" << "\n";
		else if(red==true) cout << "kou" << "\n";
		else if(pur==true) cout << "yukari" << "\n";
		else cout << "draw" << "\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin >> t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}

全部评论

相关推荐

04-03 22:41
兰州大学 C++
老六f:有时候是HR发错了,我之前投的百度的后端开发,他给我发的算法工程师,但是确实面的就是百度开发
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务