Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w przedziale [0,1] wartosci sa w przedziale [0, 0.5]
- int iter = 100;
- int count = 0;
- float x,y,f_x;
- std::vector <int> x_pod,x_nad,y_pod,y_nad;
- for (i==0; i<iter; i++);{
- x = random (0.0f , 1.0f);
- y = random (0.0f , 0.5f);
- f_x = cos(x)^2 / (x+2);
- if (y <= f_x){
- count++;
- x_pod.append(x);
- y_pod.append(y);
- }
- else{
- x_nad.append(x);
- y_nad.append(y);
- }
- }
- //draw (x_pod,y_pod) color red point
- //draw (x_nad,y_nad) color green point
- // draw (jakiś_przedział_x,f_x) black line
- return count/iter;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement