Autor Beitrag
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 15:21 
Und wieder einmal ein Hallo an die Community =).
Zu meinem Problem, ich bin grade dabei zahlreiche Programme zu programmieren und diese in einem Mainprogramm unterzubringen.Nur ich hänge bei dem FritzQuackProgramm. Es geht mal wieder um die FOR Schleife.Nur es will einfach nicht laufen.Hätte ich damals als Kind bei dem Spiel aufgepasst wär mir das jetzt warscheinlich wesentlich einfacher^^!
Die Aufgabenstellung lautet wie folgt
Es wird FritzQuack gespielt. Das Programm zählt von einem beliebigen Startwert bis zu einem beliebigen Endwert um eins hoch und ersetzt dabei jedes Vielfache von fünf durch das Wort "Fritz", jedes Vielfache von sieben durch das Wort "Quack" und jedes Vielfache von fünf und sieben durch das Wort "FritzQuack" ansonsten wird die Zahl in einer Listbox ausgegeben.
Hinweis: Ein Vielfaches von 7 heißt ganzzahlig teilbar durch 7 ohne Rest
Bei Hilfe wäre ich sehr dankbar. mfg Florian
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 19.02.06 15:25 
Und was ist nun dein Problem? :roll:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 15:56 
hallo,

Mein Fritzquack - geschrieben in 5Min :roll:


Wo ist dein Problem?
Zeig doch mal deinen Quellcode, den du bereits hast ;)
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 16:06 
Sprich: Ich verstehe das ganze Prinzip nicht,
edit: ich kriegs einfach net hin
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 19.02.06 16:33 
welches Prinzip? Wie du rasufindest ob's ein vielfaches ist?

Teile durch das zu prüfende Vielfache zB: Zahl 50; Vielfaches 7; => 50/7
Den Wert den du erhälsts untersuchst du mit Val(); ob's ein integer ist, wenn ja is die zahl 50 ein vielfaches von 7.
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 16:45 
Also den Anfang hab ich ja schonmal, 2 EingabeFelder bsp Eingabe 40 Ende 80
Zählt er mir 40-80 hoch und gibt es in der Listbox aus . Jetzt fehlt mir nur der Rest
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Var Start,i,Ende:Integer;
begin
Start:=StrToInt(edtStart.text);
Ende:=StrToInt(edtEnde.Text);
For i := Start To Ende do
 begin
 Listbox.Items.Add(IntToStr(i));
 Listbox.Refresh;
end;

Hilfe bitte :)
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 19.02.06 16:49 
Such mal nach Suche in: Delphi-Forum MOD (modulo). 50 mod 7 beispielsweise ergibt 1 (Rest), 50 mod 5 ergibt ... soweit der Ansatz - sonst könnt ich gleich die Lösung posten :roll:

AXMD
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 16:51 
Erst probier ich selber =) Hast dus denn mit mod hinbekommen?
edit: Achja wie mache ich es das ich Mod durch eine Zahl in der Listbox rechne
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Var Start,i,Ende:Integer;
    Fritz:String;
begin
Fritz:='Fritz';
Start:=StrToInt(edtStart.text);
Ende:=StrToInt(edtEnde.Text);
For i := Start To Ende do
 begin
 Listbox.Items.Add(IntToStr(i));
 if i Mod 5=0 then
  Listbox.Items.Add(Fritz);

Dann setzt er mir das Fritz aber jeweils hinter die Zahl und ersetzt sie nicht durch das Wort
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 17:55 
Habs hinbekommen =).
Letzte Frage wie führe ich 2 Mod befehle gleichzeitig aus ?
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: So 19.02.06 18:28 
ausblenden Delphi-Quelltext
1:
if (x mod y = z) and (a mod b = c) then					

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 18:42 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if (zahl mod 7 = 0and (zahl mod 5 = 0then begin
   form1.LB1.Items.Add('FritzQuack');
    exit;
     end else
      if zahl mod 5 = 0 then begin
       form1.LB1.Items.Add('Fritz');
        exit;
         end else
          if zahl mod 7 = 0 then begin
           form1.LB1.Items.Add('Quack');
             exit
               end else
      form1.LB1.Items.Add(IntToStr(zahl)) ;
Florian.K Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 19.02.06 18:46 
ich wollt zwar net die lösung haben aber danke
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 19.02.06 18:51 
oh, sry :oops:
seh's so, nun kannst du deine gesparte zeit andren problemen witwen :lol: