Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <set>
  4.  
  5. int main()
  6. {
  7. std::multimap<int, int> m;
  8. int count = 0;
  9. int key = 0;
  10. while (count != 5)
  11. {
  12. std::cout << "Enter a valid number: [1-6]" << std::endl;
  13. std::cin >> key;
  14. while (key < 0 || key > 6)
  15. {
  16. std::cout << "Your input doesn't count! Enter a valid number: [1-6]" << std::endl;
  17. std::cin >> key;
  18. }
  19. m.insert({ key, count });
  20. ++count;
  21. }
  22.  
  23. std::multiset<int> s;
  24.  
  25. for (auto it : m)
  26. {
  27. s.insert(it.first);
  28. }
  29.  
  30. for (auto it = s.begin(); it != s.end(); ++it)
  31. {
  32. if (s.count(*it) == 5)
  33. {
  34. std::cout << "yahtzee";
  35. break;
  36. }
  37.  
  38. if (s.count(*it) == 4 || (s.count(*it + 1) == 4) || (s.count(*it + 2) == 4)
  39. || (s.count(*it + 3) == 4) || (s.count(*it + 4) == 4) || (s.count(*it + 5) == 4))
  40. {
  41. std::cout << "Four of a kind!";
  42. break;
  43. }
  44.  
  45. if (s.count(*it) == 3 || (s.count(*it + 1) == 3) || (s.count(*it + 2) == 3)
  46. || (s.count(*it + 3) == 3) || (s.count(*it + 4) == 3) || (s.count(*it + 5) == 3))
  47. {
  48. s.erase(*it);
  49. auto i = s.begin();
  50. if ((s.count(*i)) == 2 || (s.count(*i)) == 3)
  51. {
  52. std::cout << "full house!";
  53. break;
  54. }
  55. else
  56. {
  57. std::cout << "Three of a kind!";
  58. break;
  59. }
  60. }
  61.  
  62. if (*it == (*it + 1) - 1 && ((s.count(*it) == 2) || (s.count(*it+1) == 2
  63. || (s.count(*it+2) == 2) || (s.count(*it+3) == 2) || (s.count(*it+4) == 2) || (s.count(*it + 5) == 2))))
  64. {
  65. std::cout << "Small straight!";
  66. break;
  67. }
  68.  
  69. if (*it == (*it + 1) - 1 && (s.count(*it) != 2) && (s.count(*it + 1) != 2)
  70. && (s.count(*it + 2) != 2) && (s.count(*it +3) != 2) && (s.count(*it + 4) != 2) && (s.count(*it + 5) != 2))
  71. {
  72. std::cout << "Large straight!";
  73. break;
  74. }
  75. std::cout << "Nothing" << std::endl;
  76. break;
  77. }
  78.  
  79. system("PAUSE");
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement