Skip to content
Snippets Groups Projects
Commit 3317d89c authored by h45-taylor's avatar h45-taylor
Browse files

created new application that shows probability of the random number in my program

parent c68a3907
Branches
No related tags found
No related merge requests found
build/
.vscode
a.out
rnd
\ No newline at end of file
......@@ -18,11 +18,9 @@
* You can use w/a/s/d or W/A/S/D to control the game.
* If there is no empty cells left with no valid moves then the game will end..
## The Aim
The aim of the game is to get one of the tiles upto a score of 2048 by combining other tiles.
* If there is no empty cells left with no valid moves then the game will end.
* If you get one of the cells to 2048 you win.
## The functions in depth
......
rnd.cpp 0 → 100644
#include <iostream>
#include <ctime>
using namespace std;
int main() {
int avg2 = 0;
int avg4 = 0;
int Loop;
srand(time(0));
for (Loop = 0; Loop < 100; Loop++)
{
int random = rand();
cout << random << endl;
int randomaftr = rand() % 2;
cout << randomaftr << endl;
int randpone = randomaftr + 1;
cout << randpone << endl;
int randmtwo = randpone * 2;
cout << randmtwo << endl;
if (randmtwo == 2)
{
avg2++;
}
if (randmtwo == 4)
{
avg4++;
}
}
cout << "After " << Loop << " loops, We have resulted in 2 a total of " << avg2 << " times and 4 " << avg4 << " times.";
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment