Está en la página 1de 4

clear

clc
a=ones(3);
b=0;
while b==0
for c=1:9
i=input('Ingrese la fila ');
j=input('ingrese la columna ');
if i>3 || i<=0
fprintf('Solo hay tres filas ')
i=input('Ingrese la fila ');
end
if j>3 || j<=0
fprintf('Solo hay tres columnas
j=input('ingrese la columna
end
if c==1 || c==3 || c==5 ||c==7 ||c==9
a(i,j)=0;
fprintf('ACABO TURNO JUGADOR UNO
else
a(i,j)=8;
fprintf('ACABO TURNO JUGADOR DOS
end

')
');

')
')

end
b=1;
end
a

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
clear
clc
a=ones(3);
b=0;
while b==0
fprintf('EL JUEGO CONSTA DE 3 FILAS Y 3 COLUMNAS LAS FICHAS ON "0" JUGADOR1 Y
"8" JUGADOR 2 ')
for c=1:9
i=input('Ingrese la fila ');
if i>3 || i<=0
fprintf('Solo hay tres filas ')
i=input('Ingrese la fila ');
end
j=input('ingrese la columna ');
if j>3 || j<=0
fprintf('Solo hay tres columnas
')
j=input('ingrese la columna
');
end
if c==1 || c==3 || c==5 ||c==7 ||c==9
a(i,j)=0;
fprintf('ACABO TURNO JUGADOR UNO
')
else
a(i,j)=8;
fprintf('ACABO TURNO JUGADOR DOS
')
end
if c>=5
if c==5 || c==7 || c==9

for j=1:3
if a(1,j)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
for j=1:3
if a(2,j)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
for j=1:3
if a(3,j)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,1)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,2)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,3)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
if a(1,1)==0 && a(2,2)==0 && a(3,3)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
if a(3,1)==0 || a(2,2)==0 || a(1,3)==0
fprintf('GANASTE JUGADOR UNO!!!!!!!')
b=1;
a
end
end
if c==6 || c==8
for j=1:3
if a(1,j)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')

b=1;
a
end
end
for j=1:3
if a(2,j)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
for j=1:3
if a(3,j)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,1)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,2)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
for i=1:3
if a(i,3)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
if a(1,1)==8 && a(2,2)==8 && a(3,3)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
if a(3,1)==8 || a(2,2)==8 || a(1,3)==8
fprintf('GANASTE JUGADOR DOS!!!!!!!')
b=1;
a
end
end
end
end
b=1;
end
a

También podría gustarte