我的代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[3][3];
int i,j=0;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
cin>>a[i][j];
}
}
int count1,count2;
int len1,len2;
len1=len2=0;
char b[50],c[2][50];
count1=count2=0;
for( i=0;i<3;i++ )
{
if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
b[j++]=a[i][0];
}
if(a[0][i]==a[1][i]&&a[1][i]==a[2][i]){
b[j++] = a[0][i];
}
}
if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
b[j++]=a[0][0];
}
if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]){
b[j++]=a[0][2];
}
len1 = j;
for(i=0;i<len1;i++){
for(j=i+1;j<len1;j++){
if(b[i]==b[j]){
b[j]='1';
}
}
}
j=0;
for(i=0;i<len1;i++){
if('A'<=b[i]&&b[i]<='Z')count1++;
}
for( i=0;i<3;i++ )
{
if(a[i][0]==a[i][1]&&a[i][0]!=a[i][2]) {
c[0][j] = a[i][0];
c[1][j++] = a[i][2];
}
if( a[i][1]==a[i][2]&&a[i][2]!=a[i][0] ){
c[0][j] = a[i][1];
c[1][j++] = a[i][0];
}
if( a[i][0]==a[i][2]&&a[i][2]!=a[i][1] ){
c[0][j] = a[i][0];
c[1][j++] = a[i][1];
}
if(a[0][i]==a[1][i]&&a[0][i]!=a[2][i]){
c[0][j] = a[0][i];
c[1][j++] = a[2][i];
}
if( a[1][i]==a[2][i]&&a[2][i]!=a[0][i] ){
c[0][j] = a[1][i];
c[1][j++] = a[0][i];
}
if( a[0][i]==a[2][i]&&a[2][i]!=a[1][i] ){
c[0][j] = a[0][i];
c[1][j++] = a[1][i];
}
}
if(a[0][0]==a[1][1]&&a[1][1]!=a[2][2]){
c[0][j] = a[0][0];
c[1][j++] = a[2][2];
}
if(a[1][1]==a[2][2]&&a[2][2]!=a[0][0]) {
c[0][j] = a[1][1];
c[1][j++] = a[0][0];
}
if(a[0][0]==a[2][2]&&a[2][2]!=a[1][1]) {
c[0][j] = a[0][0];
c[1][j++] = a[1][1];
}
if(a[0][2]==a[1][1]&&a[1][1]!=a[2][0]){
c[0][j] = a[1][1];
c[1][j++] = a[2][0];
}
if(a[1][1]==a[2][0]&&a[1][1]!=a[0][2]) {
c[0][j] = a[1][1];
c[1][j++] = a[0][2];
}
if(a[0][2]==a[2][0]&&a[0][2]!=a[1][1]) {
c[0][j] = a[0][2];
c[1][j++] = a[1][1];
}
len2 = j;
for(i=0;i<len2;i++){
for(j=i+1;j<len2;j++){
if((c[0][i]==c[0][j]&&c[1][i]==c[1][j])||(c[0][i]==c[1][j]&&c[1][i]==c[0][j])){
c[0][j]='1';
c[1][j]='1';
}
}
}
j=0;
for(i=0;i<len2;i++){
if('A'<=c[0][i]&&c[0][i]<='Z')count2++;
}
cout<<count1<<endl<<count2;
}

ACM-Team Tic Tac Toe的更多相关文章

  1. 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe

    题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...

  2. Principle of Computing (Python)学习笔记(7) DFS Search + Tic Tac Toe use MiniMax Stratedy

    1. Trees Tree is a recursive structure. 1.1 math nodes https://class.coursera.org/principlescomputin ...

  3. POJ 2361 Tic Tac Toe

    题目:给定一个3*3的矩阵,是一个井字过三关游戏.开始为X先走,问你这个是不是一个合法的游戏.也就是,现在这种情况,能不能出现.如果有人赢了,那应该立即停止.那么可以知道X的步数和O的步数应该满足x= ...

  4. 【leetcode】1275. Find Winner on a Tic Tac Toe Game

    题目如下: Tic-tac-toe is played by two players A and B on a 3 x 3 grid. Here are the rules of Tic-Tac-To ...

  5. [CareerCup] 17.2 Tic Tac Toe 井字棋游戏

    17.2 Design an algorithm to figure out if someone has won a game oftic-tac-toe. 这道题让我们判断玩家是否能赢井字棋游戏, ...

  6. Epic - Tic Tac Toe

    N*N matrix is given with input red or black.You can move horizontally, vertically or diagonally. If ...

  7. python 井字棋(Tic Tac Toe)

    说明 用python实现了井字棋,整个框架是本人自己构思的,自认为比较满意.另外,90%+的代码也是本人逐字逐句敲的. minimax算法还没完全理解,所以参考了这里的代码,并作了修改. 特点 可以选 ...

  8. LeetCode 5275. 找出井字棋的获胜者 Find Winner on a Tic Tac Toe Game

    地址 https://www.acwing.com/solution/LeetCode/content/6670/ 题目描述A 和 B 在一个 3 x 3 的网格上玩井字棋. 井字棋游戏的规则如下: ...

  9. sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里 ...

随机推荐

  1. about SpringBoot学习后记

    <SpringBoot实战>第一章节入门的名称为Spring风云再起 看起来Spring的功能确实受Java开发者喜爱 在SpringBoot中,继续将Spring框架做了另一次的封装使框 ...

  2. Vi/Vim三种模式

    命令模式,底线命令模式,输入模式:

  3. 【Python】使用Pytest集成Allure生成漂亮的图形测试报告

    前言 大概两个月前写过一篇<[测试设计]使用jenkins 插件Allure生成漂亮的自动化测试报告>的博客,但是其实Allure首先是一个可以独立运行的测试报告生成框架,然后才有了Jen ...

  4. flutter 安装详细教程

    Flutter 是 Google 用以帮助开发者在 iOS 和 Android 两个平台开发高质量原生 UI 的移动 SDK.Flutter 兼容现有的代码,免费且开源,在全球开发者中广泛被使用. 安 ...

  5. iTerm2的设置和Zsh.

    很好的说明文: https://xiaozhou.net/learn-the-command-line-iterm-and-zsh-2017-06-23.html iTerm2是Mac os用户使用的 ...

  6. Appium 自动化测试(8) -- Appium Python client -- API

    最好的学习方法,就是看源码! 在  \appium\webdriver\webdriver.py ,新增了两个封装好定位安卓元素的方法,如  find_element_by_accessibility ...

  7. linux下升级npm以及node

    npm升级 废话不多说,直接讲步骤.先从容易的开始,升级npm. npm这款包管理工具虽然一直被人们诟病,很多人都推荐使用yarn,但其使用人数还是不见减少,况且npm都是随node同时安装好的,一时 ...

  8. 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。(System.Data)

    Sql server2012连接Sql server2008时出现的问题:已成功与服务器建立连接,但在登陆过程中发生错误.(provider:SSLProvider,error:0-接收到的消息异常, ...

  9. IOS-详解KVO底层实现

    一.KVO (Key-Value Observing) KVO 是 Objective-C 对观察者模式(Observer Pattern)的实现.也是 Cocoa Binding 的基础.当被观察对 ...

  10. phython

    转载 http://www.cnblogs.com/chenny7/p/4062693.html