Zum Inhalt springen

yannic

Mitglieder
  • Gesamte Inhalte

    2
  • Benutzer seit

  • Letzter Besuch

  1. ok vielen dank jetzt klappts !
  2. Hallo Bei meinem Script, das Pi ausrechnen soll gibt es einen Fehler bei der Ausgabe. Statt Pi kommt entweder 0.000000000 oder 4.000000000 raus.Der Script ist so gedacht, dass man die Anzahl der x/y Koordinaten eingibt und dann den Nährungswert von Pi erhält.Hier ist der Script : #include <stdlib.h> #include <stdio.h> #include <time.h> int main () { int n; int i; int s = 0; double x; double y; double a; scanf("%d",&n); for(i=n;i>0;i=i-1) { srand(( unsigned )time( NULL )); x = rand() / ((double)RAND_MAX + 1); y = rand() / ((double)RAND_MAX + 1); a = sqrt(x*x+y*y); if (a<=1) s = s+1; } double res = (double)s/(double)n*4; printf("%f",res); system("pause"); return 0; } Vielleicht könnt ihr mir ja weiterhelfen !!!

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...