조회 수 1016 추천 수 0 댓글 0

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void show(int arr[10][10])
{
     system("cls");
     int i,j;
     for(i=0;i<10;i++)
    { 
       for(j=0;j<10;j++)
       {  
           printf("%c ",arr[i][j]);
         
       }
        printf("\n");
    }  
}

void changij(int arr[10][10], int pi, int pj)            {
    
    
    
    
    
    
    
 }//changij
int main(void)
{
    char eat=' ';
    char inwall=' ';
    char point=15;
    int arr[10][10]={
        {eat,eat,eat,eat,eat,eat,eat,eat,eat,eat},
        {inwall,eat,eat,eat,inwall,eat,eat,eat,eat,eat},
        {inwall,eat,inwall,eat,inwall,eat,eat,eat,inwall,eat},
        {inwall,eat,eat,eat,inwall,eat,eat,inwall,eat,eat},
        {inwall,eat,inwall,eat,inwall,inwall,eat,eat,inwall,eat},
        {eat,eat,inwall,eat,eat,eat,eat,eat,inwall,eat},
        {eat,inwall,inwall,inwall,eat,inwall,inwall,eat,inwall,eat},
        {eat,eat,inwall,eat,eat,inwall,inwall,inwall,inwall,eat},
        {inwall,eat,inwall,inwall,eat,eat,eat,inwall,eat,eat},
        {inwall,inwall,inwall,inwall,inwall,inwall,eat,eat,eat,inwall}
        };
       
       
    inwall='*';
    int i=0, j=0;
    int pi=0, pj=0;
    char ch=-32;
    char store=eat;
    char wall=inwall;
    char oldch=14;
    int k=0;
    arr[pi][pj]=point;
    show(arr);
   
    for(;;)
    {
        if(ch!=-32)
        oldch=ch;
       
        ch=getch();
       
        if(ch==-32)
        continue;

        if((ch=='l' || ch==77) && pj<9)
        {
             point=62;      
            
             if(ch==oldch)
             {
                 if(k==1)
                 {    
                       if(pi==0)
                       arr[pi][pj]=22;
                       else if(pi==9)
                       arr[pi][pj]=21;
                       else
                       arr[pi][pj]=16;
                
                 }
                 else
                 arr[pi][pj]='-';
                
                 store=arr[pi][pj+1];
                    
                     if(store==wall);
                     else
                     pj++;
                     if(store==' ' || store=='-')
                     k=0;
                     else
                     k=1;
                                         
                
             }//move

         }//(ch=='l' || ch==77) && pj<9


        if((ch=='j' || ch==75) && pj>0)
        {
             point=60;
             if(ch==oldch)
             {  
                 if(k==1)
                 {   
                      if(pi==0)
                      arr[pi][pj]=22;
                      else if(pi==9)
                      arr[pi][pj]=21;
                      else
                      arr[pi][pj]=16;
                 }
                 else
                 arr[pi][pj]='-';
                 store=arr[pi][pj-1];
                    
                     if(store==wall);
                     else
                     pj--;
                     if(store==' ' || store=='-')
                     k=0;
                     else{
                     //printf("걸림");
                     //system("pause");
                     //arr[pi][pj]=16;
                     k=1;
                     }
             }//move
        }//if
        if((ch=='i' || ch==72) && pi>0)
        {
             point=30;
             if(ch==oldch)
             {   if(k==1)
                 {    
                       if(pj==0)
                       arr[pi][pj]=25;
                       else if(pj==9)
                       arr[pi][pj]=23;
                       else
                       arr[pi][pj]=16;
                 }
                 else
                 arr[pi][pj]='|';
                 store=arr[pi-1][pj];
                    
                     if(store==wall);
                     else
                     pi--;
                     if(store==' ' || store=='|')
                     k=0;
                     else{
                     //printf("걸림");
                     //system("pause");
                     //arr[pi][pj]=16;
                     k=1;
                     }
             }//move
        }//if 
        if((ch=='k' || ch==80) && pi<9)
        {
             point=31;
             if(ch==oldch)
             {   if(k==1)
                 {
                      if(pj==0)
                      arr[pi][pj]=25;
                      else if(pj==9)
                      arr[pi][pj]=23;
                      else
                      arr[pi][pj]=16;
                 }
                 else
                 arr[pi][pj]='|';
                 store=arr[pi+1][pj];
                    
                     if(store==wall);
                     else
                     pi++;
                     if(store==' ' || store=='|')
                     k=0;
                     else{
                     //printf("걸림");
                     //system("pause");
                     //arr[pi][pj]=16;
                     k=1;
                     }
             }//move       
        }//if            
       
       
        arr[pi][pj]=point;
        show(arr);         
         
         
          }//for

   
   
   
   
    system("pause");
    return 0;
}



List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 글쓰기는 하루 5개, 댓글은 10개만 가능합니다. 좋은아빠되기 2019.02.15 588
공지 키보드 화살표값 출력 좋은아빠되기 2016.11.19 1365
공지 원하는 좌표에 값 출력하기 좋은아빠되기 2016.11.19 2681
공지 Python(파이썬) 학습 자료 PDF 1 file 좋은아빠되기 2014.12.10 10848
공지 dev C++ 텍스트 색상변경 WinApi사용(textcolor 대용) 좋은아빠되기 2014.06.07 5015
공지 DEV-C++ 기본 코드 좋은아빠되기 2013.06.19 8721
공지 무료 C++ 컴파일러(윈도우용) DEV-C++ 좋은아빠되기 2013.06.18 19264
공지 이클립스 C++ 설치 파일들 좋은아빠되기 2013.06.18 38153
89 정올 기초다지기(aD002-함수2) killerjack 2014.06.07 1117
88 정올 기초다지기(함수1-자가진단8) killerjack 2014.06.07 1392
87 정올 기초다지기(함수1-자가진단7) killerjack 2014.06.07 1211
86 정올 기초다지기(함수1-자가진단6) killerjack 2014.05.31 1455
85 정올 기초다지기(함수1-자가진단5) killerjack 2014.05.31 2605
84 정올 기초다지기(aA009-배열2 9) killerjack 2014.05.31 1324
83 정올 기초다지기(aA006-배열2 6) killerjack 2014.05.31 1212
82 정올 기초다지기(aA003-배열2 3) killerjack 2014.05.31 1433
81 정올 기초다지기(aA002-배열2 2) killerjack 2014.05.31 1291
80 정올 기초다지기(aA001-배열2 1) killerjack 2014.05.31 1445
79 정올 기초다지기(배열2-자가진단7) killerjack 2014.05.31 1515
78 정올 기초다지기(배열2-자가진단6) killerjack 2014.05.31 1438
77 정올 기초다지기(배열2-자가진단3) killerjack 2014.05.31 1589
76 정올 기초다지기 (배열2-자가진단2) killerjack 2014.05.31 1648
75 대문자 입력받아서 입력받은 횟수 출력하기 (정올 배열2-자기진단1) killerjack 2014.05.31 1717
» 작대기 그리기 노가다 killerjack 2014.05.24 1016
73 작대기 그리기 함수 killerjack 2014.05.24 943
72 별표 잡아먹기 killerjack 2014.05.17 1211
71 시계~~~ killerjack 2014.05.17 1381
Board Pagination Prev 1 ... 17 18 19 20 21 22 23 24 25 26 Next
/ 26