Pagini recente » Cod sursa (job #1532738) | Cod sursa (job #3167776) | Cod sursa (job #1424459) | Cod sursa (job #2708566) | Cod sursa (job #231009)
Cod sursa(job #231009)
program tablete;
var
a:array[1..100,1..100] of integer;
aux,k,n,i,j,x,y:integer;
f:text;
begin
assign(f,'tablete.in');
reset(f);
read(f,n); read(f,k); y:=-1;
for i:=1 to n do
for j:=1 to n do
if i mod 2=1 then begin x:=x+2;
a[i,j]:=x; end else begin
y:=y+2; a[i,j]:=y; end;
if n mod 2=0 then
begin
i:=-1;
repeat i:=i+2;
aux:=a[i,k-1];
a[i,k-1]:=a[i+1,k-1];
a[i+1,k-1]:=a[i+1,k];
a[i+1,k]:=a[i,k];
a[i,k]:=aux;
until i=n-1;
end;
for i:=1 to n do begin
for j:=1 to n do write(a[i,j]:4);
writeln; end;
readln;
close(f);
end.