#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#define A 119
#define AB 115
#define DER 100
#define IZQ 97
#define p printf
void orden ();
void caos ();
void PADRE1 ();
void SATAN1 ();
void SANTO1 ();
void JESUS1 ();
void padre ();
void satan();
void jesus();
void santo();
void bit();
void interaccion();
int V[4][4] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int aux, aux1=0,aux2=0,aux3=0,aux4=0,aux5=0;
int a,b,ba;
int main()
{
time_t t;
srand((unsigned) time(&t));
for(a=0;a<3;a++)
{
caos();
}
bit();
orden();
interaccion();
return 0;
}
void orden()
{
int a,b;
for(a=0;a<=3;a++)
{
for(b=0;b<=3;b++)
{
p("%d\t",V[a]);
}
p("\n");
}
}
void caos()
{
int b1 = 0;
int e,f;
do{
b1 = 0;
e= rand()% 4;
f= rand()% 4;
if(V[f][e]==0)
{
V[f][e] = 2;
b1 = 1;
}
}while(b1==0);
}
void PADRE1()
{
do{
ba=0;
for(a=1;a<=3;a++)
{
for(b=0;b<=3;b++)
{
if(V[a-1]==0&&V[a]!=0)
{
V[a-1]=V[a];
V[a]=0;
ba=1;
}
}
}
}while (ba=1);
}
void SATAN1()
{
do{
ba=0;
for(a=2;a>=0;a--)
{
for(b=0;b<=3;b++)
{
if(V[a+1]==0&&V[a]!=0)
{
V[a+1]=V[a];
V[a]=0;
ba=1;
}
}
}
}while(ba==1);
}
void SANTO1()
{
do
{
ba=0;
for (a=0;a<=3;a++)
{
for (b=1;b<=3;b++)
{
if(V[a][b-1]==0&&V[a]!=0)
{
V[a][b-1]=V[a];
V[a]=0;
ba=1;
}
}
}
}while (ba=1);
}
void JESUS1()
{
do{
ba=0;
for (a=0;a<=3;a++)
{
for (b=2;b>=0;b--)
{
if(V[a][b-1]==0&&V[a]!=0)
{
V[a][b-1]=V[a];
V[a]=0;
ba=1;
}
}
}
}while (ba==1);
}
void padre ()
{
for (a=1;a<=3;a++)
{
for (b=0;b<4;b++)
{
if (V[a-1]==V[a])
{
V[a-1]+=V[a];
V[a]=0;
}
}
}
}
void satan()
{
for (a=2;a>=0;a--)
{
for (b=0;b<4;b++)
{
if (V[a+1]==V[a])
{
V[a+1]+=V[a];
V[a]=0;
}
}
}
}
void jesus ()
{
for(a=0;a<=3;a++)
{
for(b=2;b>=0;b--)
{
if(V[a][b+a]==V[a])
{
V[a][b+1]+=V[a];
V[a]=0;
}
}
}
}
void santo()
{
SANTO1();
for(a=0;a<=3;a++)
{
for(b=1;b<=3;b++)
{
if(V[a][b-1]==V[a])
{
V[a][b-1]+=V[a];
V[a]=0;
}
}
}
}
void bit()
{
p("Utilice:\nw para arriba\ns para abajo\npara derecha a\npara izquierda d \n\n\n\n");
system("pause");
system("cls");
}
void interaccion()
{
int i,e,f,a;
int t1, band=0;
time_t t;
do
{
t1=getch();
switch(t1)
{
case A:
PADRE1 ();
padre();
PADRE1 ();
caos ();
system ("cls");
break;
case AB:
SATAN1();
satan();
SATAN1();
caos ();
system ("cls");
break;
case IZQ:
SANTO1();
santo();
SANTO1();
caos ();
system ("cls");
break;
case DER:
JESUS1;
jesus();
JESUS1();
caos ();
system ("cls");
break;
default:
{
p("\n\n\n\tTECLA ERRONEA\n\n");
system("pause");
system("cls");
break;
}
}
orden();
}
while((aux1==1)||(aux2==1)||(aux3==1)||(aux4==1)||(aux5==1));
p("TERMINO EL JUEGO");
}
Imprimes un mensaje indicando qué se debe ingresar los comandos pero, ¿Cómo haces para leer lo que se ingresa? no veo que invoques al metodo scanf.
orden= imprimir matriz
caos= numeros aleatorios / posicion aleatoria
padre= mover numeros arriba
satan= mover numeros abajo
jesus= mover numeros hacia la derecha
santo= mover numeros hacia la izquierda
bit= funcion para instrucciones
interaccion= funcion para poder introducir comandos w,a,s,d
TODOS LOS QUE ESTEN EN MAYUSCULAS Y TENGAN UN 1 SE RECORREN HACIA LA MISMA DIRECCION DEL QUE ESTA EN MINUSCULAS Y NO TIENE UN NUMERO Y SUMA EN EL CASO DE QUE SEAN IGUALES.
Me sale este error: error: incompatible types when assigning to type 'int[4]' from type 'int'
if( V[a][b-1] == V[a] )
{
V[a][b-1] +=V[a];
V[a]=0;
}
V es una matriz 4x4 no puedes acceder a sus elementos de esa manera, prueba con V[n][m], V[0][1],V[3][3]..etc.. o como lo que está marcado de azul
tenes el codigo completo sin errores?