Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- int main()
- {
- int m;
- int n;
- int k = 0;
- string pause;
- cout << "Iveskite m:" << endl;
- cin >> m;
- cout << "Iveskite n:" << endl;
- cin >> n;
- int length = to_string(n).length();
- for (int i = m; i <= n; i++) {
- string number = to_string(i);
- int tempNumberLength = number.length() - 1;
- bool luckyNumber = true;
- if (tempNumberLength + 1 >= 6) {
- for (int x = 0; x < 3; x++) {
- if (number.at(x) != number.at(tempNumberLength - x)) {
- luckyNumber = false;
- }
- }
- if (luckyNumber) {
- k++;
- }
- }
- }
- cout << "Laimingus bilietus isigijo k = " + to_string(k) + " keleiviu" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement