1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
using namespace std;
int main(){
double r, probred,e,z,c,q;
int countr,countb,countz,red,blue,p;
red= 1;
blue= -1;
countr=0;
countb=0;
countz = 0;
srand(time(NULL));
for (int a=0; a<100; a++){
probred = 0.01;
r = ((double) rand()/(RAND_MAX+1));
e = ((double) rand()/(RAND_MAX+1));
q = exp(-e);
p = a;
if (probred > r && r < q) {
z=red;
countr = countr+1;
}//closes if statement
else
z=0;
countz = countz+1;
cout << p << " , " << r << " , " << z << " , " << e << " , " << q << " , " << countr << " , " << countz << endl;
if (countr == 1) {
cout <<" nucleation" << endl;
return p;
break;
}//closes if statement
}//closes for loop
}//closes main
|