AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein [Suche]Hilfe bei Turbo Pascal Lottozahl Generator
Thema durchsuchen
Ansicht
Themen-Optionen

[Suche]Hilfe bei Turbo Pascal Lottozahl Generator

Ein Thema von crisbinfranke · begonnen am 9. Feb 2010 · letzter Beitrag vom 16. Feb 2010
Antwort Antwort
pluto47

Registriert seit: 15. Jun 2008
1 Beiträge
 
#1

Re: [Suche]Hilfe bei Turbo Pascal Lottozahl Generator

  Alt 9. Feb 2010, 21:18
Hallo Christian,

für Lottozahlen bietet sich der Datentyp Menge also "set of" an.
Durch das Auslesen mit der Abfrage "IN" erübrigt sich das Sortieren.

Delphi-Quellcode:
program lottozahlen;
uses crt;

type
  TLottozahl = 1..49;
  TLottotipp = set of TLottozahl;

var Lottozahl: TLottozahl;
    Lottotipp: TLottotipp;
    i:integer;

begin
  Lottotipp := []; { Der Lottotipp ist zunächst die Leere Menge }                  

  Randomize;
  for i:=1 to 6 do { Es werden 6 Lottozahlen gezogen }
    begin
      Repeat
        Lottozahl := Random(49)+1; { Wird so lange wiederholt bis eine neue Zahl gefunden wird }
      Until not(Lottozahl in Lottotipp);
      Lottotipp := Lottotipp + [Lottozahl]; { Vereinigungsmenge aus Lottotipp und der neuen Lottozahl }
    end;

  for Lottozahl:=1 to 49 do
    begin
      if Lottozahl in Lottotipp then { Sucht die gezogenen Zahlen der Größe nach heraus }
         write( Lottozahl , ' ' );
    end;
end.
Kann sein, dass noch einige Syntaxfehler enthalten sind, da ich den Code nicht mit Turbo-Pascal erstellt habe.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:34 Uhr.
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