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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
using namespace std;
int main(){
int v,box[100],aman[100],z,red,blue,counter,p;
double r,e,q,b,probred;
red=1;
blue=-1;
counter=0;
while (counter < 101){
for (int a=1; a<101; a++){
z=0;
box[a] = a;
aman[a] = a*z;
cout << box[a] << "," << aman[a]<<endl;
Sleep(1000);
if (aman[a] == 0){
cout << box[a] << aman[a]<<endl;
Sleep(1000);
// b = ((double) rand()/(RAND_MAX+1));
// b= exp(-b)*1000;
// Sleep(b);
probred = 0.01;
r = ((double) rand()/(RAND_MAX+1));
e = ((double) rand()/(RAND_MAX+1));
q = exp(-e);
if (probred > r && r < q) {
z=red;
counter=counter+1;
aman[a] = box[a];
}//closes if statement
else if ( r < q){
z=blue;
aman[a] = a*-1;
counter=counter+1;
}//closes if statement
else
z=0;
aman[a] = a*z;
}//closes if statement
cout << "box is: " << box[a] <<"," <<" binding is: " << aman[a] << "," <<" counter is: "<< counter << endl;
Sleep(2000);
if(counter == 100){
break;
}//closes if statement
}//closes for loop*/
}//closes while loop
}//closes main
|