Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 0.95 KB | None | 0 0
  1.     cifra_correcta(f,c:INTEGER):BOOLEAN is
  2.     local
  3.         i,j:INTEGER
  4.     do
  5.         from i:=1
  6.         until   i>9 or Result=FALSE
  7.         loop
  8.             -- Comprueba repeticiones en la fila
  9.             if (c+i <=9) then
  10.                 if (tablero.item(f,c).numero = tablero.item(f,c+i).numero) then Result:=FALSE end
  11.             else
  12.                 if (tablero.item(f,c).numero = tablero.item(f,(c+i\\9)).numero) then Result:=FALSE end
  13.             end
  14.             -- Comprueba repeticiones en la columna
  15.             if (f+i<=9) then
  16.                 if (tablero.item(f,c).numero = tablero.item(f+i,c).numero) then Result:=FALSE end
  17.             else
  18.                 if (tablero.item(f,c).numero = tablero.item((f+i)\\9,c).numero) then Result:=FALSE end
  19.             end
  20.         end
  21.        
  22.         from i:=1
  23.         until i>3
  24.         loop
  25.             from j:=1
  26.             until j>3
  27.             loop
  28.             if (c+j)<=3 then
  29.                 if (tablero.item(f,c).numero = tablero.item((f+i),(j+i)).numero) then Result:=FALSE end
  30.             else
  31.                 if (tablero.item(f,c).numero = tablero.item((f+i)\\3,(j+i)\\3).numero) then Result:=FALSE end
  32.             end
  33.             end
  34.         end
  35.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement