fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int SIZE = 18;
  5. int accountNumbers[SIZE] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850,
  6. 8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
  7. 1005231, 6545231, 3852085, 7576651, 7881200, 4581002};
  8. bool isValid(int number) {
  9. for (int i = 0; i < SIZE; ++i) {
  10. if (accountNumbers[i] == number) {
  11. return true;
  12. }
  13. }
  14. return false;
  15. }
  16. int main() {
  17. int inputNumber;
  18. cout << "Enter a charge account number: ";
  19. cin >> inputNumber;
  20. if (isValid(inputNumber))
  21. {
  22. cout << "That is a valid account number." << endl;
  23. } else
  24. {
  25. cout << "That is not a valid account number." << endl;
  26. }
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5304KB
stdin
3852085
stdout
Enter a charge account number: That is a valid account number.