Pagini recente » Cod sursa (job #178589) | Cod sursa (job #1211359) | Cod sursa (job #2882221) | Cod sursa (job #2630412) | Cod sursa (job #232078)
Cod sursa(job #232078)
var f:text;
a:array[1..170,1..170]of integer;
l,j,n,i,k:longint;
z:longint;
begin
assign(f,'tableta.in');reset(f);
read(f,n,k);
for i:=1 to n do for j:=1 to n do a[i,j]:=0;
z:=n*n+1;
l:=n;
for i:=n downto 1 do
begin
for j:=n downto k+1 do
if a[i,j]=0 then
begin z:=z-1;
a[i,j]:=z;
end;
z:=z-1;
if z mod 2<>0 then
if i>1 then
begin a[i-1,n]:=z;z:=z-1;
end
else
begin
a[l,k-1]:=z;z:=z-1;
l:=l-1;
end;
a[i,k]:=z;
end;
z:=0;
for i:=1 to n do
for j:=1 to k-1 do
if a[i,j]=0 then
begin
inc(z);
a[i,j]:=z;
end;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
end.