Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- #include <Windows.h>
- using namespace std;
- class MasterMind
- {
- public:
- void wczytaj(int zgaduj[]);
- void poprawne_answers(int answers[]);
- void play_game();
- };
- void MasterMind::poprawne_answers(int answers[])
- {
- srand((unsigned int)time(NULL));
- for (int k = 0; k <= 3; k++)
- answers[k] = rand() % 10;
- //cout << "1. Poprawna: " << answers[0] << endl;
- //cout << "2. Poprawna: " << answers[1] << endl;
- //cout << "3. Poprawna: " << answers[2] << endl;
- //cout << "4. Poprawna: " << answers[3] << endl;
- }
- void MasterMind::wczytaj(int zgaduj[])
- {
- cout << "Podaj proponowane odpowiedzi: " << endl;
- for (int i = 0; i <= 3; i++)
- cin >> zgaduj[i];
- }
- void MasterMind::play_game()
- {
- int zgadywane[3];
- int poprawne[3];
- int l, i;
- int good = 0, pomoc = 0;
- poprawne_answers(poprawne);
- wczytaj(zgadywane);
- l = 0;
- for (i = 0; i <= 3; i++)
- {
- if (zgadywane[i] == poprawne[l])
- good++;
- l++;
- }
- cout << "Ilosc idealnie trafionych liczb: "<< good << endl;
- // cout << "Ilosc liczb, ktore znajduja sie w innym, niz podanym przez Ciebie miejscu: " << pomoc << endl;
- }
- int main()
- {
- MasterMind gra;
- gra.play_game();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement