Cod sursa(job #788539)
Utilizator | Data | 15 septembrie 2012 12:17:26 | |
---|---|---|---|
Problema | Arbori de intervale | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int x ,x0,x1,step;
x0 = 0; x1 = 0;
step = 1000000;
for(int i=0;i<step;i++)
{
x = rand()%2;
if(x==0)x0++;
if(x==1)x1++;
}
printf("%d\n",step);
printf("%.2lf %.2lf\n",double(x0)/step*100.0,double(x1)/step*100.0);
}