Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <time.h>
  4. #include "windows.h"
  5. #include "winioctl.h"
  6. using namespace std;
  7.  
  8. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  9.  
  10. int main(int argc, char** argv) {
  11.  
  12.     srand (time(NULL));
  13.     for (int i=0;i<=4;i++) {
  14.  
  15.         double j = 0, summe = 0, mittel = 0, min = 1, max = 0, anz = 0;
  16.         cout <<i<< endl;
  17.         do {
  18.             double j = ((double) rand()/RAND_MAX);
  19.             printf("\nDie Zufallszahl lautet:   ");
  20.             cout << j << endl;
  21.             anz ++;
  22.             summe += j;
  23.             mittel = summe / anz;
  24.                        
  25.             if (j>=max) {
  26.                 max = j;
  27.             }  
  28.             if (j <= 1) {
  29.                 min = j;
  30.             }
  31.             if(j >= 0.85){
  32.                 break;
  33.             }
  34.             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);
  35.         } while (1==1);
  36.         printf("\nZufallszahl ueber 0.85 gefunden\n");
  37.  
  38.     }
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement