#include
#include
#include
#include
#include
int count=1;
volatile int getBin(){
int i, j;
unsigned long ts = time(NULL);
count += 12497023;
srand((unsigned int)ts * count);
j=rand();
if(j>(RAND_MAX/3))
return 1;
else return 0;
}
volatile int getBin_N(){
int i, j;
unsigned long ts = time(NULL);
count += 12497023;
srand((unsigned int)ts * count);
j=rand();
if(j>(RAND_MAX/3))
return 0;
else return 1;
}
int main()
{
double c=0,t=0;
while(1)
{
t+=2;
c+=(double)getBin()+(double)getBin_N();
printf("ratio=%5.2f\%\r\b",c / t * 100.0);
}
return 0;
}
阅读(591) | 评论(0) | 转发(0) |