You are on page 1of 4

Nombre:Calderon accha Gianpierre Codigo:10170099 Ejercicio 1 function sudoku(A) c=0;i=1; n=input('ingrese un numero ') A(i)=n; for i=2:16 n=input('ingrese

un numero ') c=0; for j=1:i if n==A(j) c=c+1; end end if c==0 A(i)=n; else while c>0 n=input('ingrese un numero diferente a los ingresados ') c=0; for j=1:i if A(j)==n c=c+1; end end end A(i)=n; end end A

>> v=zeros(1,16) v= 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

>> sudoku(v) ingrese un numero 9 n= 9 ingrese un numero 8

n= 8 ingrese un numero 3 n= 3 ingrese un numero 6 n= 6 ingrese un numero 1 n= 1 ingrese un numero 2 n= 2 ingrese un numero 3 n= 3 ingrese un numero diferente a los ingresados 4 n= 4 ingrese un numero 5 n= 5 ingrese un numero 6 n= 6

ingrese un numero diferente a los ingresados 7

n= 7 ingrese un numero 8 n= 8 ingrese un numero diferente a los ingresados 9 n= 9 ingrese un numero diferente a los ingresados 20 n= 20 ingrese un numero 11 n= 11 ingrese un numero 12 n= 12 ingrese un numero 14 n= 14 ingrese un numero 19 n=

19 ingrese un numero 18 n= 18 ingrese un numero 17

n= 17 A=

7 20 11 12 14 19 18 17

You might also like