Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <time.h>
- #include "windows.h"
- #include "winioctl.h"
- using namespace std;
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char** argv) {
- srand (time(NULL));
- for (int i=0;i<=4;i++) {
- double j = 0, summe = 0, mittel = 0, min = 1, max = 0, anz = 0;
- cout <<i<< endl;
- do {
- double j = ((double) rand()/RAND_MAX);
- printf("\nDie Zufallszahl lautet: ");
- cout << j << endl;
- anz ++;
- summe += j;
- mittel = summe / anz;
- if (j>=max) {
- max = j;
- }
- if (j <= 1) {
- min = j;
- }
- if(j >= 0.85){
- break;
- }
- printf("\n Es gibt %d Versuche. Der Mittelwert betraegt : %d, \n Die Summe ist bei : %d. Das Maximum liegt bei %d und das Minimum bei %d", anz, mittel, summe, max, min);
- } while (1==1);
- printf("\nZufallszahl ueber 0.85 gefunden\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement