Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. w przedziale [0,1] wartosci sa w przedziale [0, 0.5]
  2.  
  3. int iter = 100;
  4. int count = 0;
  5. float x,y,f_x;
  6. std::vector <int> x_pod,x_nad,y_pod,y_nad;
  7.  
  8. for (i==0; i<iter; i++);{
  9.     x = random (0.0f , 1.0f);
  10.     y = random (0.0f , 0.5f);
  11.     f_x = cos(x)^2 / (x+2);
  12.     if (y <= f_x){
  13.         count++;
  14.         x_pod.append(x);
  15.         y_pod.append(y);
  16.     }
  17.     else{
  18.         x_nad.append(x);
  19.         y_nad.append(y);
  20.     }
  21. }
  22. //draw (x_pod,y_pod) color red point
  23. //draw (x_nad,y_nad) color green point
  24. // draw (jakiś_przedział_x,f_x) black line
  25. return count/iter;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement