U E D R , A S I H C RSS

김영록/연구중/지뢰찾기

....( ㅠㅠㅠ)

~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;
			
			}
		}
	}	
}

/////////////////////////////////////////////////////////

mine1.JPG
mine2.JPG


ㅡ,.ㅡ;; 200;;

히 X,Y ㅡ,.ㅡ;;;



...ㅎㅎ .. ..
? ㅎㅎㅎㅎ ..ㅎㅎㅎ
..ㅎㅎ
.. 편하..ㅎㅎㅎ
ㅎㅎㅎ ^^ -
! ! -






Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:49
Processing time 0.0197 sec