Zitat von thosch97C Alles anzeigen#include <iostream> #include <cstdlib> #include <time.h> /* * ---------------------------------------------------------------------------- * "THE PIZZA-WARE LICENSE" (Revision 23): * <thosch97@googlemail.com> wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a pizza in return Thomas Schneider * ---------------------------------------------------------------------------- */ using namespace std; int main(void) { cout << "Bitte geben Sie die Anzahl der Tropfen ein: "; int tropfenanzahl; cin >> tropfenanzahl; long double pi; int gesamt = tropfenanzahl; int innerhalb = 0; srand ( time(NULL) ); while(tropfenanzahl > 0) { double dotx = ((double) rand()) / RAND_MAX; double doty = ((double) rand()) / RAND_MAX; if (dotx*dotx + doty*doty <= 1) { innerhalb++; } //cout << (gesamt-tropfenanzahl)+1 << ". Durchgang" << endl; tropfenanzahl--; } pi = 4*(long double)innerhalb/gesamt; cout << "Pi ist ungefähr " << pi << endl; return 0; }Mit freundlicher Hilfe von gandro.
(Für die Windowsler die das Ergebnis sehen wollen gibts btw unter http://t23h.de/files/pi.exe n fertigen Build)
Dir ist klar, dass dein Build unter Windows 98 nicht geht? Wenn ich das durch Dev C++ jage, gehts aber ![]()