#include <time.h>
#include <math.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#define ROW 9
#define COL 9
int printboard(int grid[ROW][COL]){
int x,y,n,chk;
srand(time(NULL));
for(x=0;x<ROW;x++){
for(y=0;y<COL;y++){
do{
n=rand()%7+2;
grid[x][y]=n;
if (((grid[x][y]==grid[x-1][y]) && (grid[x][y]==grid[x-2][y])) || ((grid[x][y]==grid[x][y-1]) && (grid[x][y]==grid[x][y-2]))){
chk=1;
continue;
}else{
chk=0;
printf("%d ", n);
}
}while(chk==1);
}
printf("\n\n");
}
}
int welcome(char name[20]){
printf("********************WELCOME********************\n");
printf("*****************NUMBER CRUSH******************\n\n");
printf("Please key in your name:");
scanf("%s",name);
printf("***Good day %s,let's start a new game...all the best!!!***\n\n\n", name);
fflush(stdin);
return 0;
}
int menu(c){
int choose;
do{
printf("*MENU\n");
printf("*Press 2 to move down\n");
printf("*Press 4 to move left\n");
printf("*Press 6 to move right\n");
printf("*Press 8 to move up\n");
printf("*Press 5 to switch\n");
printf("*Press 0 to quit\n");
printf("Please enter your choose: ");
scanf("%i",&choose);
if(choose==2){
}else if(choose==4){
}else if(choose==6){
}else if(choose==8){
}else if(choose==5){
}else if(choose==0){
printf("Exit the program!");
}else{
printf("Invalid Input!\n\n");
}
}while(choose!=0);
return 0;
}
int main(){
int arr[ROW][COL];
char name[20];
int c;
welcome(name);
printboard(arr);
menu(c);
return 0;
}
above is my coding, i try to make a box inside the 2d array the can be move around.