SHARE
TWEET

Untitled

a guest Oct 13th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main()
  6. {
  7.  
  8.     float nbverif;
  9.     float verifproba;
  10.     for (int nbspaghetti = 1; nbspaghetti < 1000001; nbspaghetti++)
  11.     {
  12.         float random1 = (float)rand() / RAND_MAX;
  13.  
  14.         float l1 = random1;
  15.         float l2 = 1 - l1;
  16.         float random2 = (float)rand() / RAND_MAX;
  17.  
  18.         float l3 = random2 * (1 - l1);
  19.         float l4 = 1 - l3 - l1;
  20.         if (l1 > l3 && l1 > l4)
  21.         {
  22.             if (l1 < (l3 + l4))
  23.             {
  24.                 nbverif = nbverif + 1.0;
  25.             }
  26.         }
  27.         else if (l3 > l1 && l3 > l4)
  28.         {
  29.             if (l3 < (l1 + l4))
  30.             {
  31.                 nbverif = nbverif + 1.0;
  32.             }
  33.         }
  34.         else if (l4 > l1 && l4 > l3)
  35.         {
  36.             if (l4 < (l3 + l1))
  37.             {
  38.                 nbverif = nbverif + 1.0;
  39.             }
  40.         }
  41.     }
  42.     verifproba = nbverif / 1000000;
  43.     printf("%f", verifproba);
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top