Autor Beitrag
gimnick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

SuSE Linux, Win 98 SE
D7 Enterprise, Kylix
BeitragVerfasst: Sa 10.07.04 16:50 
hi,

möchte als anfänger ein kleines pi nach monte-carlo programm erstellen.

hier mein code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var     x,y: real;
        k,n,t: longint;
begin
        t := 0;
        randomize;
        for k := 1 to n do
        begin
                x := random;
                y := random;
                if x*x+y*y <= 1 then t := t+1;
        end;
        Label1.Caption := "Pi = " + 4+t/n;
end;


Als Fehlermeldung kommtdas hier, beide für Zeile 12:
Ungültiges Zeichen in der Quelldatei "" $22;
Inkompatible Typen: 'WideString' und 'Boolean'

Was kann/soll ich damit anfangen?
MfG Jan


Zuletzt bearbeitet von gimnick am Sa 10.07.04 17:13, insgesamt 1-mal bearbeitet
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 10.07.04 17:05 
Mach aus den beiden " doch mal bitte je ein '...
Könntest Du auch noch einen trefferenden Titel wählen? Klick einfach auf den Edit Button rechts oberhalb deines Posts... Danke!

raziel

_________________
JSXGraph
gimnick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

SuSE Linux, Win 98 SE
D7 Enterprise, Kylix
BeitragVerfasst: Sa 10.07.04 17:16 
hi,

hab jetzt mal die " durch ' ersetzt.
nur noch ein fehler:
in zeile 12 ... inkompatible Typen 'String' und 'Interger'

MfG Jan

(Sorry aber bin echt ein noob) ;)

_________________
Lieber 6 Stunden Schule, als gar keinen Schlaf!
Blitz.XP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 10.07.04 17:17 
Ich blick nicht richtig was der qualtext da oben soll, aber wenn man pi berechnen will geht das auhc ganz einfach mit
pi ;)
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 10.07.04 17:18 
Im Gegensatz zu BASIC, PHP und Co darfst Du bei Delphi keine Strings (Zeichenketten) und Integer (Zahlen) mischen! Mit   Label1.Caption := "Pi = " + FloatToStr(4+(t/n)); dürfte auch das Problem gelöst sein...

raziel

_________________
JSXGraph
gimnick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

SuSE Linux, Win 98 SE
D7 Enterprise, Kylix
BeitragVerfasst: Sa 10.07.04 17:26 
danke, dieses problem ist gelöst ;)

jetzt sieht der code so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var     x,y: real;
        k,n,t: longint;
begin
        n := StrToInt(Anzahl.Text);
        t := 0;
        randomize;
        for k := 1 to n do
        begin
                x := random;
                y := random;
                if x*x+y*y <= 1 then t := t+1;
        end;
        Label1.Caption := 'Pi = ' + FloatToStr((4*t/n));
end;


musste noch das 4+t/n durch 4+t/n ersetzen und fertig ist das programm ;)


nun kommt aber was blödes:
verwende ja Linux und wollte das programm starten da kommt dieser fehler:

./Project1: relocation error: ./Project1: undefined symbol: initPAnsiStrings

MfG JanZ

_________________
Lieber 6 Stunden Schule, als gar keinen Schlaf!
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Sa 10.07.04 17:37 
Werf mal google an. Damit wirst du 100%-tig mehrere hundert Seiten finden, die diesen Fehler behandlen.

_________________
Ist Zeit wirklich Geld?
Blitz.XP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 10.07.04 17:40 
Junge warum stresst ihr so? Wenn ihr pi haben wollt, danns chreib tieinafch hin: Label1.caption := 'Pi = '+floattostr(pi); das wars!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 10.07.04 17:43 
Es geht wohl eher darum, sich mit der Methode auseinander zu setzen, als Pi herauszubekommen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Blitz.XP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 10.07.04 17:45 
Ich emin nur: Warum das rad doppelt erfinden?
gimnick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

SuSE Linux, Win 98 SE
D7 Enterprise, Kylix
BeitragVerfasst: Sa 10.07.04 17:54 
hi,

@ Blitz.XP: "möchte als anfänger ein kleines pi nach monte-carlo programm erstellen." ;)

MfG Jan

_________________
Lieber 6 Stunden Schule, als gar keinen Schlaf!
gimnick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

SuSE Linux, Win 98 SE
D7 Enterprise, Kylix
BeitragVerfasst: So 11.07.04 11:31 
hi,

jetzt ist wieder ein anderes poblem *würg*

wenn ich es starten will, kommt folgender fehler:

ausblenden Quelltext
1:
2:
janz@linux:~> /home/JanZ/Documents/Delphi_Projekte/Pi berechnen/Project1
bash: /home/JanZ/Documents/Delphi_Projekte/Pi: Datei oder Verzeichnis nicht gefunden

_________________
Lieber 6 Stunden Schule, als gar keinen Schlaf!
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 11.07.04 12:20 
Leerzeichen im Ordnername. Das kann nur schiefgehen, wenn man nicht weiß, was man macht.

_________________
Ist Zeit wirklich Geld?
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 11.07.04 12:40 
Neue Frage, neuer Thread :mahn:

Aber diesmal als Ausnahme:
Entweder janz@linux:~> /home/JanZ/Documents/Delphi_Projekte/Pi \berechnen/Project1 oder janz@linux:~> "/home/JanZ/Documents/Delphi_Projekte/Pi berechnen/Project1"

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert


Zuletzt bearbeitet von tommie-lie am So 11.07.04 13:35, insgesamt 1-mal bearbeitet
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 11.07.04 13:24 
Sitzt der \ nicht vielleicht ein Zeichen zu weit hinden? :wink:

_________________
Ist Zeit wirklich Geld?
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 11.07.04 13:37 
Ich bin mir nicht sicher, ich meine aber, daß das Leerzeichen da richtig ist (und auf keinen Fall "Pi\ berechnen"). Aber sowas kann man ja ausprobieren, wenn man eine bash laufen hat ;-)
Aber die zweite Alternative (mit Anführungszeichen) hat nicht gestimmt, da war der Backslash noch drin, gehörte aber nicht da rein.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert