Autor Beitrag
liquid air
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: So 06.11.05 23:14 
also, hi erstmal, ich hab vor kurzem mal mit delphi angefangen und progge (bzw versuche es) im mom erstmal n paar programme um eben zu testen was ich so kann, wie das alles geht etc. ^^

im mom arbeite ich an nem programm, bei dem man eine zahl eingibt, und dann soll das prog alle zahlen von 0 (bzw 2) bis zu der zahl ausgeben, die primzahlen sind.
so, wie es im mom aufgebaut is, gibt es mir aber irgendwas mit 3, 5, 7, 7, 13, 13... oder so oO und dann wirds noch komischer gegen ende...
naja also ne fehlermeldung vom prog aus kommt zwar net, aber es is halt trotzdem komisch...ich zeig euch einfach mal den quellcode:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, math,
  StdCtrls;

type
  TForm1 = class(TForm)
    LAusgabe: TLabel;
    EEingabe: TEdit;
    BLos: TButton;
    BEnde: TButton;
    procedure BLosClick(Sender: TObject);
    procedure BEndeClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  A, B, C, D:integer;
  S: string;
implementation

{$R *.DFM}

procedure TForm1.BLosClick(Sender: TObject);
begin
 S:='';
 A:=StrToInt(EEingabe.text);
for D:=2 to A do


  for B:=2 to Trunc(sqrt(D)) do
   begin
    C:=D mod B;
     if C=1 then
      begin
       S:=S + IntToStr(D) + ' ,';
      end
     else 
   end;

   
LAusgabe.caption:=S;
end;

procedure TForm1.BEndeClick(Sender: TObject);
begin
 close;
end;

end.
liquid air Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mo 07.11.05 00:31 
ok inzwischen hab ich durch zufall gemerkt dass es hauptsächlich daran lag, dass ich "break" statt "exit" holen muss...das wusst ich halt net; sry falls sich jetzt jemand aufregen sollte ^^"

für alle die es interessiert; hier der fertige, funktionierende script:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, math,
  StdCtrls;

type
  TForm1 = class(TForm)
    LAusgabe: TLabel;
    EEingabe: TEdit;
    BLos: TButton;
    BEnde: TButton;
    procedure BLosClick(Sender: TObject);
    procedure BEndeClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  A, B, C, D:integer;
  S: string;
  pz: boolean;
implementation

{$R *.DFM}

procedure TForm1.BLosClick(Sender: TObject);
begin
 S:='';
 A:=StrToInt(EEingabe.text);
for D:=2 to A do begin
  for B:=2 to Trunc(sqrt(D)) do
   begin
    C:=D mod B;
     if C=0 then
      begin
       pz:=false;
       break;
      end
     else if c=1 then
      begin
       pz:=true;
      end;
   end;
 if pz=true then begin
 S:=S+IntToStr(D)+' ,';
 end;
end;

LAusgabe.caption:=S;
end;

procedure TForm1.BEndeClick(Sender: TObject);
begin
 close;
end;

end.




//edit: ok, danke!

_________________
Matthias K.


Zuletzt bearbeitet von liquid air am Mo 07.11.05 01:38, insgesamt 2-mal bearbeitet
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 07.11.05 01:34 
Ich verweise auch mal auf diesen Thread:
www.delphi-forum.de/...unktion_33013,0.html

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)