fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 294, 10
  2. //
  3. /**************************************************************
  4.  * Search number.
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will tell the user if the entered number is vaild or not.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * user_num : user number.
  11.  * OUTPUT
  12.  * If the number entered is vaild or not.
  13.  **************************************************************/
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cmath>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. // Initialize the list of valid charge account numbers
  22. const int SIZE = 18;
  23. int user_num;
  24. bool found = false;
  25. int validNumbers[SIZE] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850,
  26. 8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
  27. 1005231, 6545231, 3852085, 7576651, 7881200, 4581002};
  28. cout<<"Please enter your user number."<<endl;
  29. cin>>user_num;
  30. for (int i = 0; i < SIZE; i++)
  31. {
  32. if (validNumbers[i] == user_num)
  33. {
  34. found = true;
  35. }
  36.  
  37. }
  38. if (found == true)
  39. {
  40. cout<<"Your number is vaild"<<endl;
  41. }
  42. else
  43. {
  44. cout<<"Your number is invaild."<<endl;
  45. }
  46.  
  47.  
  48. return 0 ;
  49. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty