Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //libraries
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <math.h>
- #include <ctime>
- #include <windows.h>
- #include <vector>
- using namespace std;
- void ShowHorse(int horse, int position) {
- cout << horse+1 << "|";
- for (int i = 0; i < position; i++)
- cout << "-";
- cout << "H";
- for (int i = position + 1; i < 15; i++)
- cout << "-";
- cout << "|" << endl;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int rand1 = 0;
- int positions[3];
- memset(positions, 0, 3 * sizeof(int));
- bool done = false;
- srand(time(NULL));
- while (!done) {
- for (int horse = 0; horse < 3; horse++) {
- int rand1 = rand() % 100 + 1;
- if (rand1 >= 50)
- positions[horse]++;
- }
- // at this point, all the horses positions are updated, now let's draw them!
- cout << endl;
- for (int horse = 0; horse < 3; horse++) {
- ShowHorse(horse, positions[horse]);
- }
- for (int i = 0; i < 3; i++)
- if (positions[i] == 14)
- {
- cout << "Horse " << i + 1 <<" won!" <<endl;
- done = true;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement