Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- /*
- ABCDE * 4 = EDCBA
- */
- int main() {
- ostringstream ss;
- int limit = 100000;
- for (int i = 10000; i < limit; i++) {
- int i4 = i * 4;
- if (i4 >= limit) break;
- ss << i;
- string is = ss.str(); //string i
- ss.str("");
- string isr = ""; //string i, reversed
- for (int x = is.length() - 1; x >= 0; x--) {
- isr += is.at(x);
- }
- ss << i4;
- string i4s = ss.str(); //string i4
- ss.str("");
- cout << "i:" << i << " 4*i:" << i4 << " ir:" << isr << endl;
- if (i4s == isr) {
- cout << "Najdeno! " << i << endl;
- break;
- }
- }
- }
- /*
- int i
- string i
- int i4 = i * 4
- string i4
- proveri dali i4 == i.reverse()
- */
Advertisement
Add Comment
Please, Sign In to add comment