program mang hai chieu; program xoan oc; uses crt; var a array[1 50,1 50] of integer; i,j,n,h,dem integer; begin clrscr; write(''''nhap n ''''); readln(n); for h =1 to trunc(n div 2) do begin for j =h to n[.]
program xoan_oc; uses crt; var a:array[1 50,1 50] of integer; i,j,n,h,dem: integer; begin clrscr; write('nhap n: '); readln(n); for h:=1 to trunc(n div 2) begin for j:=h to n-h begin inc(dem); a[h,j]:=dem; end; for i:=h to n-h begin inc(dem); a[i,n-h+1]:=dem; end; for j:=n-h+1 downto h+1 begin inc(dem); a[n-h+1,j]:=dem; end; for i:=n-h+1 downto h+1 begin inc(dem); a[i,h]:=dem; end; end; {neu n chan thi vong lap tren se chay het tat ca cac vi tri ma n le thi khong chay toi duoc vi tri trung tam cua mang nen phai ep vao} if n mod 20 then a[round(n/2),round(n/2)]:=n*n; {in ra} writeln('ket qua:'); for i:=1 to n begin for j:=1 to n write(a[i,j]:4); writeln; end; readln; end