Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<time.h>
- #define MAX(x, y) (((x) > (y)) ? (x) : (y))
- #define MIN(x, y) (((x) < (y)) ? (x) : (y))
- int main()
- {
- int i,j,s1,s2,s,r;
- srand(time(NULL));
- s=500;
- for(i=0,j=0;i<1000000;i++)
- {
- s1=rand()%1000;
- s2=rand()%1000;
- if(rand()%2==0) r=s1; else r=s2;
- if(r<=s && r==MIN(s1,s2)) j++;
- else if(r>s && r==MAX(s1,s2)) j++;
- }
- printf("%f",(float) j/i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement