Cod sursa(job #242974)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 11 ianuarie 2009 16:53:20
Problema Tablete Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.35 kb
program tableta;

{$APPTYPE CONSOLE}

uses
  SysUtils;
 var i,j,n,k,t:integer;fin,fout:text; b,curent:longint;
 a:array [1..1001,1..1001] of integer;
 use:array [1..1000001] of byte;
begin
  { TODO -oUser -cConsole Main : Insert code here }
assign (fin,'tableta.in');reset(fin);
assign(fout,'tableta.out');rewrite(fout);
readln(fin,n,k);
//writeln(fout,'ok');
b:=1 ; curent:=1;
for i:=1 to n do begin
for j:=1 to n do begin
                     if j=k then begin
                                   if b mod 2 =0 then begin
                                                                a[i,k]:=b ;use [b]:=1;
                                                           end  else begin
                                                                        a[i,k]:=b+1; use[b+1]:=1;
                                                                      end;
                                 end else begin
                                 while use[curent]=1 do inc(curent);
                                             a[i,j]:=curent;use [curent]:=1;inc(curent);
                                         end;
                 b:=b+1; 
                 end;
                 end;
for i:=1 to n do begin
for j:=1 to n do begin
                      write(fout,a[i,j],' ');
                 end; writeln(fout);
                 end;
close(fout);
end.