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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
system ("color C");
int i = 0;
int loop = 0;
int loop2 = 0;
int total = 0;
int track = 0;
/*int Raph = 0;
int Mikey = 0;
int Leo = 0;
int Don = 0;
int Splinter = 0;
int Shredder = 0;
int April = 0;
int Kraang = 0;*/
int array1[8] = {0, 0, 0, 0, 0, 0, 0, 0}; //this doesn't work
srand(time(NULL));
loop = 1000; // How many loops the function does
loop2 = 1000; // How many times the program runs
for (int q = 0; q < loop2; q++)
{
for (int j = 0; j<loop;j++)
{
i = rand()%8+1; //shows a range from 1-8
if (i == 1) //if 1, increase Raph value
{
array1[0]++;
}
if (i == 2) //if 2, increase Mikey value
{
array1[1]++;
}
if (i == 3) //if 3, increase Leo value
{
array1[2]++;
}
if (i == 4) //if 4, increase Don value
{
array1[3]++;
}
if (i == 5) //if 5, increase Splinter value
{
array1[4]++;
}
if (i == 6) //if 6, increase Shredder value
{
array1[5]++;
}
if (i == 7) //if 7, increase April value
{
array1[6]++;
}
if (i == 8) //if 8, increase Kraang value
{
array1[7]++;
}
break;
}
track += array1[0];
array1[8] = 0;
}
if(array1[0] >1&& array1[1]>1 && array1[2] > 1 && array1[3] > 1&& array1[4]>1 && array1[5] > 1 && array1[6] > 1 && array1[7] > 1)
{
float final = track / 1000;
cout<<"It took you an average of " << final << "/1000 tries to get at least one of each toy.\n\n";
}
else
{
cout<<"Sorry, even after 1000 tries you did not collect at least one of each toy :( \n\n";
}
system ("pause");
return 0;
}
|