fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int SIZE = 10;
  5. const int luckyNum[SIZE] = {13579, 26791, 26792, 33445, 55555,
  6. 62483, 77777, 79422, 85647, 93121};
  7.  
  8. bool isWinner(int winningNum) {
  9. for (int i = 0; i < SIZE; ++i) {
  10. if (winningNum == luckyNum[i]) {
  11. return true;
  12. }
  13. }
  14. return false;
  15. }
  16.  
  17. int main() {
  18. int winningNum;
  19. cout << "Enter this week's winning 5-digit number: ";
  20. cin >> winningNum;
  21.  
  22. if (isWinner(winningNum)) {
  23. cout << "Congratulations! You have a winning ticket this week." << endl;
  24. } else {
  25. cout << "Sorry, none of your tickets are winners this week." << endl;
  26. }
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5300KB
stdin
79422
stdout
Enter this week's winning 5-digit number: Congratulations! You have a winning ticket this week.