Advertisement
Guest User

Untitled

a guest
Dec 30th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <cstdlib>
  4. #include <Windows.h>
  5.  
  6. using namespace std;
  7.  
  8. class MasterMind
  9. {
  10. public:
  11. void wczytaj(int zgaduj[]);
  12. void poprawne_answers(int answers[]);
  13. void play_game();
  14. };
  15.  
  16. void MasterMind::poprawne_answers(int answers[])
  17. {
  18. srand((unsigned int)time(NULL));
  19.  
  20. for (int k = 0; k <= 3; k++)
  21. answers[k] = rand() % 10;
  22.  
  23. //cout << "1. Poprawna: " << answers[0] << endl;
  24. //cout << "2. Poprawna: " << answers[1] << endl;
  25. //cout << "3. Poprawna: " << answers[2] << endl;
  26. //cout << "4. Poprawna: " << answers[3] << endl;
  27. }
  28.  
  29. void MasterMind::wczytaj(int zgaduj[])
  30. {
  31. cout << "Podaj proponowane odpowiedzi: " << endl;
  32. for (int i = 0; i <= 3; i++)
  33. cin >> zgaduj[i];
  34. }
  35.  
  36. void MasterMind::play_game()
  37. {
  38. int zgadywane[3];
  39. int poprawne[3];
  40. int l, i;
  41. int good = 0, pomoc = 0;
  42.  
  43. poprawne_answers(poprawne);
  44. wczytaj(zgadywane);
  45.  
  46. l = 0;
  47. for (i = 0; i <= 3; i++)
  48. {
  49. if (zgadywane[i] == poprawne[l])
  50. good++;
  51.  
  52. l++;
  53. }
  54.  
  55.  
  56. cout << "Ilosc idealnie trafionych liczb: "<< good << endl;
  57. // cout << "Ilosc liczb, ktore znajduja sie w innym, niz podanym przez Ciebie miejscu: " << pomoc << endl;
  58.  
  59.  
  60.  
  61. }
  62.  
  63. int main()
  64. {
  65.  
  66. MasterMind gra;
  67. gra.play_game();
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement