#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.

Recommended Answers

All 4 Replies

what compiler are you using? You could draw a box by using the line-drawing bytes of the ascii character set (the values between 179 and 223). google for "ascii character set" and you will find the table of all possible 255 values and a picture of they they look like when printed (assuming your computer is set up to use ascii character set).

im using quincy 2005, so i need to make the box using code

to do something like this

There's a space between each of the numnbers in that huge square, which leaves room for the |, _ and - characters areound the number in the center.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.