Pagini recente » Cod sursa (job #1775351) | Cod sursa (job #2439157) | Cod sursa (job #2793516) | Cod sursa (job #1182885) | Cod sursa (job #230751)
Cod sursa(job #230751)
{Tablete --> Algoritmiada 2009}
var f,g:text;
n,k,cont,i,j,a:longint;
begin
assign(f,'tablete.in'); reset(f);
assign(g,'tablete.out'); rewrite(g);
read(f,n); Read(f,k); close(f);
cont:=1;
if (n mod 2 = 0) and (k mod 2 =0) then
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
write(g,cont,' '); Inc(cont);
end;
writeln(g);
end;
end
else
begin
cont:=2;
for i:=1 to n-1 do
begin
if i=n-1 then
begin
for j:=1 to n-1 do
begin write(g,cont,' '); inc(cont); end;
cont:=cont+2; a:=cont; write(g,cont,' ');
writeln(g); write(g,1,' '); cont:=cont-2;
for j:=1 to n do
begin if (cont <> a) and (cont<=n*n) then write(g,cont,' '); Inc(cont); end;
end
else
begin
for j:=1 to n do
begin write(g,cont,' '); Inc(cont); end;
writeln(g);
end;
end;
end;
Close(g);
end.