티스토리 뷰


package javaapplication3;
import java.io.*;
public class JavaApplication3 {

 
    public static void main(String[] args ) throws IOException{
     BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    
       int omok[][]=new int[8][8];
       int x,y,result=0,cnt;
      

/*--------------------오목배열 초기화-------------*/
       for(int i=0; i<8; i++)
           for(int j=0; j<8; j++)
               omok[j][i]=0;
      
      
       System.out.println("오목프로그램 시작.(초기화완료)");
      
/*-----------------게임시작-----------------------------------------------*/
         while(true)
       {
           System.out.printf("오목판에 오목을 놓거라!\n");
           System.out.print("X축입력:");
            x=Integer.parseInt(in.readLine());
            System.out.print("Y축입력:");
            y=Integer.parseInt(in.readLine());
            if(x>7||y>7||omok[y][x]==1)
            {
                System.out.printf("다시입력해!\n");
                continue;
            }
            omok[y][x]=1;
           
           
 /*----------------출력부분-----------------*/
       for(int i=0; i<8; i++){
           for(int j=0; j<8; j++)
               System.out.printf("%d  ",omok[i][j]);
           System.out.printf("\n");
                                }
      
/*----------------검사시작------------------*/
      
     
/*-----------------x축검사-------------------*/
       cnt=0;
       for(int i=0; i<7; i++)
      {
         
          if(omok[y][i]==1&&omok[y][i]==omok[y][i+1])
              cnt++;
          if(cnt>=4)
              result=1;
             
      }          
      
/*----------------y축검사------------------*/
       cnt=0;
      for(int i=0; i<7; i++)
      {
          if(omok[i][x]==1&&omok[i][x]==omok[i+1][x])
              cnt++;
          if(cnt>=4)
              result=1;
             
      }    
/*----------------대각선축검사------------------*/
   
     
     
     
/*--------------------------------result판단-------------*/
       if(result==1){
           System.out.printf("게임종료\n");
           break;
       }
      
/*----------------검사종료------------------*/      
        }
/*-----------------게임종료 -----------------------------------------------*/
                              
      
                      
       }
   
    }


 

 

'IT Skills > Programming' 카테고리의 다른 글

Linux vi편집기 사용법(한글깨짐오류처리방법포함)&&telnet 기본적인 사용법  (0) 2013.04.02
JAVA - 오목 만들어보기 2  (0) 2013.04.01
C#-2  (0) 2013.03.25
java  (0) 2013.03.25
[C#] 기본  (0) 2013.03.11
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함