Pagini recente » Cod sursa (job #2379552) | Cod sursa (job #1183497) | Cod sursa (job #373646) | Cod sursa (job #2747736) | Cod sursa (job #242974)
Cod sursa(job #242974)
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.