Загрузка данных


program diamond;

var
  n, k: integer;

procedure PrintChars(count: integer);
begin
  if count > 0 then
  begin
    write('*');
    if count > 1 then
      write(' ');
    PrintChars(count - 1);
  end;
end;

procedure PrintSpaces(count: integer);
begin
  if count > 0 then
  begin
    write(' ');
    PrintSpaces(count - 1);
  end;
end;

procedure PrintLine(k, n: integer);
begin
  PrintSpaces(n + 1 - k);
  PrintChars(1);
  if k > 1 then
  begin
    PrintSpaces(2 * k - 3);
    PrintChars(1);
  end;
  writeln;
end;

procedure DrawTop(k, n: integer);
begin
  if k <= n + 1 then
  begin
    PrintLine(k, n);
    DrawTop(k + 1, n);
  end;
end;

procedure DrawBottom(k, n: integer);
begin
  if k >= 1 then
  begin
    PrintLine(k, n);
    DrawBottom(k - 1, n);
  end;
end;

begin
  repeat
    write('Enter the diamond''s height (positive odd): ');
    readln(n);
  until (n > 0) and (n mod 2 = 1);

  n := n div 2;
  DrawTop(1, n);
  DrawBottom(n, n);
end.