include
include
include
int count=10;
int flag=1;
int disbomb[10][10];
int a[10][10];
extern void makebomb();
extern void countbomb(int x,int y);
extern void printbomb();
extern void gameover();
int main(){
int X;
int Y;
printf("*****\n");
printf("*auther:Akavice**\n");
printf("**please enter x and y*\n\n\n");
printf(" ");
for(int k=0;k<10;k++){
printf("%d ",k);
}
printf("\n\n");
for(int i=0;i<10;i++){
printf("%d ",i);
for(int j=0;j<10;j++){
printf("%d ",a[i][j]);
}
printf("\n");
}
makebomb();
while(flag){
scanf("%d %d",&X,&Y);
if(disbomb[X][Y]==0){
countbomb(X,Y);
printbomb();
}else{
gameover();
flag=0;
}
}
return 0;
}
void makebomb(){
srand((int)time(0));
int x;
int y;
while(count>0){
x=(int)(rand()%10);
y=(int)(rand()%10);
if(disbomb[x][y]!=1){
disbomb[x][y]=1;
count--;
}
}
}
void countbomb(int x,int y){
int bombcount=0;
if((disbomb[x-1][y-1])&&(disbomb[x-1][y-1]==1))
bombcount+=1;
if((disbomb[x][y-1])&&(disbomb[x][y-1]==1))
bombcount+=1;
if((disbomb[x+1][y-1])&&(disbomb[x+1][y-1]==1))
bombcount+=1;
if((disbomb[x-1][y])&&(disbomb[x-1][y]==1))
bombcount+=1;
if((disbomb[x+1][y])&&(disbomb[x+1][y]==1))
bombcount+=1;
if((disbomb[x-1][y+1])&&(disbomb[x-1][y+1]==1))
bombcount+=1;
if((disbomb[x][y+1])&&(disbomb[x][y+1]==1))
bombcount+=1;
if((disbomb[x+1][y+1])&&(disbomb[x+1][y+1]==1))
bombcount+=1;
a[x][y]=bombcount;
}
void printbomb(){
printf(" ");
for(int k=0;k<10;k++){
printf("%d ",k);
}
printf("\n\n");
for(int i=0;i<10;i++){
printf("%d ",i);
for(int j=0;j<10;j++){
printf("%d ",a[i][j]);
}
printf("\n");
}
}
void gameover(){
printf("YOU LOST,GAME OVER\n");
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
printf("%d ",disbomb[i][j]);
}
printf("\n");
}
}
void makesign(){
}