Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. int m;
  9. int n;
  10. int k = 0;
  11.  
  12. string pause;
  13.  
  14. cout << "Iveskite m:" << endl;
  15. cin >> m;
  16. cout << "Iveskite n:" << endl;
  17. cin >> n;
  18.  
  19. int length = to_string(n).length();
  20.  
  21. for (int i = m; i <= n; i++) {
  22. string number = to_string(i);
  23. int tempNumberLength = number.length() - 1;
  24. bool luckyNumber = true;
  25.  
  26. if (tempNumberLength + 1 >= 6) {
  27.  
  28. for (int x = 0; x < 3; x++) {
  29. if (number.at(x) != number.at(tempNumberLength - x)) {
  30. luckyNumber = false;
  31. }
  32. }
  33.  
  34. if (luckyNumber) {
  35. k++;
  36. }
  37. }
  38.  
  39.  
  40. }
  41.  
  42. cout << "Laimingus bilietus isigijo k = " + to_string(k) + " keleiviu" << endl;
  43.  
  44. system("pause");
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement