ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1319. Hotel

Accepted
Posted by Delpher 19 Apr 2011 19:47
program Project1319;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a                  : array [0 .. 100, 0 .. 100] of integer;
  i, j, n, k, x, key : integer;

begin
  readln(n);
  k := 2;
  x := 1;
  key := 2*n;
//*****************************************************************
  repeat
    for I := 1 to n do begin
      for J := 1 to n do begin
        if I+J = k then begin
          a[i, j] := x;
          inc(x)
        end;
      end;
    end;
    inc(k)
  until k > key;
//*****************************************************************
  for i := 1 to n do begin
    for j := n downto 1 do
      write(a[i, j]:5);
    writeln
  end;
end.