Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package tiktakto;
- import java.util.Scanner;
- /**
- *
- * @author Sharif
- */
- public class Tiktakto {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner sc = new Scanner(System.in);
- int moves = sc.nextInt();
- int board[][] = new int[4][4];
- for(int i=1; i<=moves; i++)
- {
- int row,col,symbol;
- row= sc.nextInt();
- col=sc.nextInt();
- symbol= sc.nextInt();
- board[row][col]=symbol;
- }
- System.out.println();
- for(int i=1; i<=3;i++)
- {
- for(int j=1; j<=3; j++)
- System.out.print(board[i][j]+" ");
- System.out.println("");
- }
- if(board[1][1]==board[1][2]&&board[1][2]==board[1][3]&&(board[1][1]==1||board[1][1]==2))
- result(board[1][1]);
- else if(board[2][1]==board[2][2]&&board[2][2]==board[2][3]&&(board[2][1]==1||board[2][1]==2))
- result(board[2][1]);
- else if(board[3][1]==board[3][2]&&board[3][2]==board[3][3]&&(board[3][1]==1||board[3][1]==2))
- result(board[3][1]);
- else if(board[1][1]==board[2][1]&&board[2][1]==board[3][1]&&(board[1][1]==1||board[1][1]==2))
- result(board[1][1]);
- else if(board[1][2]==board[2][2]&&board[2][2]==board[3][2]&&(board[1][2]==1||board[1][2]==2))
- result(board[1][2]);
- else if(board[1][3]==board[2][3]&&board[2][3]==board[3][3]&&(board[1][3]==1||board[1][3]==2))
- result(board[1][3]);
- else if(board[1][1]==board[2][2]&&board[2][2]==board[3][3]&&(board[1][1]==1||board[1][1]==2))
- result(board[1][1]);
- else if(board[1][3]==board[2][2]&&board[2][2]==board[3][1]&&(board[1][3]==1||board[1][3]==2))
- result(board[1][3]);
- else
- System.out.println("no one is win");
- }
- static void result(int r)
- {
- if(r==1)
- System.out.println("1 is win");
- else if(r==2)
- System.out.println("2 is win");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement