fork download
  1. #include <iostream>
  2.  
  3. struct Card {
  4. public:
  5. enum Suits { Hearts, Diamonds, Clubs, Spades } Suit;
  6. int Index;
  7. int Value;
  8.  
  9. Card(int index, int value, Suits suit) : Index(index), Value(value), Suit(suit) {}
  10. };
  11.  
  12. bool spiderCanStackOn(const Card& bottom, const Card& top)
  13. {
  14. return bottom.Value == top.Value - 1;
  15. }
  16. bool spiderCanMoveWith(const Card& bottom, const Card& top)
  17. {
  18. return spiderCanStackOn(bottom, top) && bottom.Suit == top.Suit;
  19. }
  20. bool klondikeCanStackOn(const Card& bottom, const Card& top)
  21. {
  22. bool red1, red2;
  23. red1 = bottom.Suit == Card::Suits::Hearts || bottom.Suit == Card::Suits::Diamonds;
  24. red2 = top.Suit == Card::Suits::Hearts || top.Suit == Card::Suits::Diamonds;
  25. return spiderCanStackOn(bottom, top) && red1 != red2;
  26. }
  27. bool klondikeCanMoveWith(const Card& bottom, const Card& top)
  28. {
  29. return klondikeCanStackOn(bottom, top);
  30. }
  31.  
  32. int main() {
  33. // your code goes here
  34. return 0;
  35. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
Standard output is empty