Pagini recente » Cod sursa (job #2398651) | Cod sursa (job #3227405) | Cod sursa (job #355785) | Cod sursa (job #1625023) | Cod sursa (job #232084)
Cod sursa(job #232084)
var f:text;
a:array[1..200,1..200]of integer;
l,j,n,i,k:integer;
z:longint;
begin
assign(f,'tablete.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;
assign(f,'tablete.out');rewrite(f);
for i:=1 to n do
begin
for j:=1 to n do
write(f,a[i,j],' ');
writeln(f);
end;
close(f);
end.