Pagini recente » Cod sursa (job #490096) | Cod sursa (job #488035) | Cod sursa (job #749375) | Cod sursa (job #1778235) | Cod sursa (job #242971)
Cod sursa(job #242971)
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 integer;
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.