Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Upon further clarification in the comments section:</p> <p>Yes, you can represent your number as a std::string in C++.</p> <p><a href="http://rosettacode.org/wiki/Increment_a_numerical_string#C.2B.2B" rel="nofollow noreferrer">Here</a> you find code for incrementing a number represented as a string:</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; #include &lt;ostream&gt; void increment_numerical_string(std::string&amp; s) { std::string::reverse_iterator iter = s.rbegin(), end = s.rend(); int carry = 1; while (carry &amp;&amp; iter != end) { int value = (*iter - '0') + carry; carry = (value / 10); *iter = '0' + (value % 10); ++iter; } if (carry) s.insert(0, "1"); } int main() { std::string big_number = "123456789012345678901234567899"; std::cout &lt;&lt; "before increment: " &lt;&lt; big_number &lt;&lt; "\n"; increment_numerical_string(big_number); std::cout &lt;&lt; "after increment: " &lt;&lt; big_number &lt;&lt; "\n"; } </code></pre> <p>You can use this in a loop to increment your big number and <a href="https://stackoverflow.com/a/8362657/227755">check if the resulting string is a palindrome</a>:</p> <pre><code>if( equal(s.begin(), s.begin() + s.size()/2, s.rbegin()) ) std::cout &lt;&lt; "is a palindrome.\n"; else std::cout &lt;&lt; "is NOT a palindrome.\n"; </code></pre> <p><strong>Edit</strong></p> <p>I do not claim this to be an efficient and correct solution to the problem. It's just a representation and incrementing method for big numbers.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload