Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Multi-Dimensional (Arrays) HELP!

Shelbyyy

Recruit
Basic Member
Messages
1
Reaction score
0
Points
16
Tama po ba yung code ko? Kasi parang kulang/may mali sa code ko pag ni rurun ko po eh. Patulong naman po. Thank you!!!

Yung gusto ko pong gawin ay (see attached image)

Eto po yung code na ginawa ko
--------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void imprimeGrid(char (*card)[4])
{
int f,c;
printf(" 1 2 3 4\n");
for (f = 0; f<4; f++)
{
printf(" %i ",f+1);
for (c=0; c<4; c++)
{
printf(" [$] ",card[f][c]);
}
printf("\n");
}
}
void juego()
{
int x1,y1,x2,y2;
char card[4][4];
printf ("Memory Game!: \n\n");
card[0][0]='1';
card[0][1]='2';
card[0][2]='3';
card[0][3]='4';
card[1][0]='2';
card[1][1]='3';
card[1][2]='1';
card[1][3]='4';
card[2][0]='4';
card[2][1]='3';
card[2][2]='2';
card[2][3]='1';
card[3][0]='2';
card[3][1]='4';
card[3][2]='1';
card[3][3]='3';

printf("Please insert the row: ");
scanf("%i",&x1);
printf("Please insert the column: ");
scanf("%i",&y1);
x1=x1-1;
y1=y1-1;


printf("\n \n");
printf("Please insert the row: ");
scanf("%i",&x2);
printf("Please insert the column: ");
scanf("%i",&y2);
x2=x2-1;
y2=y2-1;


int f,c;
printf(" 1 2 3 4\n");
for (f = 0; f<4; f++)
{
printf(" %i ",f+1);
for (c=0; c<4; c++)
{
if ((f==x1) && (c==y1))
{
printf(" [%c] ",card[f][c]);
}
if ((f==x2) && (c==y2))
{
printf(" [%c] ",card[f][c]);
}
else
{
printf(" [X] ");
}
}
printf("\n");
}



}

int main()
{
int again = 0;
do
{
juego();
printf("Enter 1 to play again. Enter 0 to quit. ");
scanf("%i",&again);
} while(again);
}
 

Attachments

  • aaaa.JPG
    aaaa.JPG
    43.9 KB · Views: 9
Last edited:
Back
Top Bottom