Pi/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Pi/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | \ | |
| 2 | + | π ist das Verhältnis des Umfangs eines Kreises zu seinem Durchmesser.\ | |
| 3 | + | Der Wert von π ist in etwa 3,14159265358979.\ | |
| 4 | + | Der Umfang eines Kreises wird enweder mit\ | |
| 5 | + | U = π (2 * r)\ | |
| 6 | + | oder mit\ | |
| 7 | + | U = π * d\ | |
| 8 | + | berechnet.\ | |
| 9 | + | \ | |
| 10 | + | In Pascal ist pi eine Funktion, die den Wert von π zurückgibt.\ | |
| 11 | + | \ | |
| 12 | + | π/4 ist das gleiche wie arctan(1).\ | |
| 13 | + | \ | |
| 14 | + | Sämtliche Trigonometrische Funktionen (sin, cos, etc.) werden mit FPC im Bogenmass berechnet. Dies entspricht 360° = 2 * Pi.\ | |
| 15 | + | \ | |
| 16 | + | \ | |
| 17 | + | Olaf 20:06, 20 November 2016 (CET) | |
| 18 | + | ||
| 19 | + | ## Pi hoch aufgelöst | |
| 20 | + | ||
| 21 | + | Will man **Pi** sehr genau ausrechnen, kann man sich mit folgender Procedure behelfen. | |
| 22 | + | ||
| 23 | + | ``` pascal | |
| 24 | + | program Project1; | |
| 25 | + | ||
| 26 | + | uses | |
| 27 | + | Crt; | |
| 28 | + | ||
| 29 | + | var | |
| 30 | + | stellen: integer; | |
| 31 | + | ||
| 32 | + | procedure CalcPi; | |
| 33 | + | var | |
| 34 | + | r, p: string; | |
| 35 | + | m, i, j, u, z: integer; | |
| 36 | + | ||
| 37 | + | c: array of integer; | |
| 38 | + | begin | |
| 39 | + | SetLength(c, 10 * (Stellen + 1) div 3 + 1); | |
| 40 | + | r := ''; | |
| 41 | + | p := ''; | |
| 42 | + | m := 10 * (Stellen + 1) div 3; | |
| 43 | + | for i := 1 to m do begin | |
| 44 | + | c[i] := 2; | |
| 45 | + | end; | |
| 46 | + | for j := 0 to Stellen do begin | |
| 47 | + | if j mod 100 = 0 then begin | |
| 48 | + | GotoXY(1, 1); | |
| 49 | + | WriteLn('Stelle: ', j); | |
| 50 | + | end; | |
| 51 | + | ||
| 52 | + | u := 0; | |
| 53 | + | for i := m downto 2 do begin | |
| 54 | + | z := 10 * c[i] + u; | |
| 55 | + | c[i] := z mod (i * 2 - 1); | |
| 56 | + | u := z div (i * 2 - 1) * (i - 1); | |
| 57 | + | end; | |
| 58 | + | z := 10 * c[1] + u; | |
| 59 | + | c[1] := z mod 10; | |
| 60 | + | u := z div 10; | |
| 61 | + | if u <= 8 then begin | |
| 62 | + | r := r + p; | |
| 63 | + | p := Chr(48 + u); | |
| 64 | + | end; | |
| 65 | + | if u = 9 then begin | |
| 66 | + | p := p + Chr(48 + u); | |
| 67 | + | end; | |
| 68 | + | if u = 10 then begin | |
| 69 | + | for i := 1 to Length(p) do begin | |
| 70 | + | Val(p[i], z, u); | |
| 71 | + | Inc(z); | |
| 72 | + | if z = 10 then begin | |
| 73 | + | z := 0; | |
| 74 | + | end; | |
| 75 | + | p[i] := Chr(48 + z); | |
| 76 | + | end; | |
| 77 | + | p := p + '0'; | |
| 78 | + | end; | |
| 79 | + | end; | |
| 80 | + | p := r[1] + '.' + Copy(r, 2, Length(r)) + p; | |
| 81 | + | WriteLn(p); | |
| 82 | + | SetLength(c, 0); | |
| 83 | + | end; | |
| 84 | + | ||
| 85 | + | begin | |
| 86 | + | ClrScr; | |
| 87 | + | Writeln('Bitte Stellen eingeben: '); | |
| 88 | + | readln(stellen); | |
| 89 | + | CalcPi; | |
| 90 | + | end. | |
| 91 | + | ``` | |
| 92 | + | ||
| 93 | + | --- | |
| 94 | + | *From the Free Pascal wiki, page "Pi/de", as it stood on 2018-02-11 after a change by Mathias, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 95 | + | Category: Pascal/de |
