기 ¶
구....( ㅠㅠㅠ)
¶
~cpp #include <iostream.h> #include <stdlib.h> #include <time.h> static int space[16][16]; static int gameover=1; //0경 void mine_confirm(int X, int Y); // void mine_update(int X, int Y); // 경 그근 void mine_newgame(); // 기 void mine_show(); // 기 void mine_menu(); // ///////////////////////////////////////////////////////// void main() { mine_newgame(); mine_show(); while(gameover) { mine_menu(); } } ///////////////////////////////////////////////////////// void mine_menu() // { int num_x,num_y; while(1){ num_x = 0; num_y = 0; cout << "X ? (1~20): "; cin >> num_x; cout << "Y ? (1~20): "; cin >> num_y; if (1<=num_x<=20) if (1<=num_y<=20) break; cout << "값." << endl; } mine_confirm(num_x-1,num_y-1); } void mine_show() { int a,b; cout << endl << endl<< endl<< endl<< endl<< endl<< endl; cout << " ======기 1.00======" << endl; for (a=0 ; a!=16 ; a++){ cout << " "; for (b=0 ; b!=16 ; b++){ switch(space[b][a]){ case 10 : cout << "■"; break; case 9 : cout << "■"; break; default : cout << space[b][a] << " " ; } } cout << endl; } } ///////////////////////////////////////////////////////// void mine_update(int X, int Y) { int mine_count; mine_count = 0; if(X-1 >= 0 && Y-1 >= 0){ if (space[X-1][Y-1] == 9){ mine_count++; } } if(Y-1 >= 0){ if (space[X][Y-1] == 9){ mine_count++; } } if(X+1 <= 15 && Y-1 >= 0){ if (space[X+1][Y-1] == 9){ mine_count++; } } if(X-1 >= 0 ){ if (space[X-1][Y] == 9){ mine_count++; } } if(X+1 <= 15){ if (space[X+1][Y] == 9){ mine_count++; } } if(X-1 >= 0 && Y+1 <= 15){ if (space[X-1][Y+1] == 9){ mine_count++; } } if(Y+1 <= 15){ if (space[X][Y+1] == 9){ mine_count++; } } if(X+1 <=15 && Y+1 <= 15){ if (space[X+1][Y+1] == 9){ mine_count++; } } space[X][Y] = mine_count; mine_show(); } /////////////////////////////////////////////////////////// void mine_confirm(int X, int Y) { if (space[X][Y] ==9){ gameover = 0; cout << endl<< endl<< endl<< endl; cout << endl << " ====YOU step MINE AND BOOM===="; cout << endl << " ============GAME OVER=============" <<endl; int a,b; for (a=0 ; a!=16 ; a++){ cout << " "; for (b=0 ; b!=16 ; b++){ switch(space[b][a]){ case 10 : cout << "■"; break; case 9 : cout << ""; break; default : cout << space[b][a] << " " ; } } cout << endl; } char c; cout << "겠까?(y/n) : "; cin >> c ; if (c == 'y'){ gameover = 1; mine_newgame(); mine_show(); } } else if(space[X][Y] ==10) mine_update(X,Y); } ///////////////////////////////////////////////////////// void mine_newgame() { int i; int a,b; for (a=0 ; a!=16 ; a++){ for (b=0 ; b!=16 ; b++){ space[b][a] = 10; } } // 기 srand(time(NULL)); // 값 결 for (i=0;i!=40;i++){ while(1) { int x,y; x=rand()%15+0; y=rand()%15+0; if (space[x][y] != 9){ space[x][y] = 9; break; } } } } /////////////////////////////////////////////////////////
기 ¶
기 기 ㅡ,.ㅡ;; 200;;
기 근 게 겟 ㅠ
게 X,Y ㅡ,.ㅡ;;;
ㅠ