Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Sternchenmuster erstellen (https://www.delphipraxis.net/37735-sternchenmuster-erstellen.html)

Phantom1 9. Jan 2005 21:16

Re: Sternchenmuster erstellen
 
Hier ist noch eine möglichkeit von mir:

Delphi-Quellcode:
program dreieck_links;

{$APPTYPE CONSOLE}

uses SysUtils;

var
  max: Byte;

procedure DrawStars(anz: Byte);
var Stars: String;
begin
  Stars:=StringOfChar(' ', (max-anz) div 2) + StringOfChar('*', anz);
  WriteLn(Stars);
  if anz>1 then begin
    DrawStars(anz-2);
    WriteLn(Stars);
  end;
end;

begin
  Write('Wieviel Sterne: ');
  ReadLn(max);
  // Wir brauchen eine ungerade Anzahl, dass wir in der Mitte einen Stern bekommen
  if max mod 2 = 0 then Inc(max, 1);
  DrawStars(Max);
  ReadLn;
end.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:17 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz