Created
August 31, 2015 18:17
-
-
Save codepainkiller/ea7cb626c7dcf7c40045 to your computer and use it in GitHub Desktop.
20vo numero capicua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| bool isCapicua(int num) | |
| { | |
| int a = num; | |
| int c = 0; | |
| int b = 0; | |
| while(a != 0) | |
| { | |
| b = a % 10; | |
| a = a / 10; | |
| c = (c * 10) +b; | |
| } | |
| if (c == num) | |
| return true; | |
| return false; | |
| } | |
| int capicua20() | |
| { | |
| int contador = 0; | |
| int it = 100; | |
| int capicua = 0; | |
| while (contador < 20) | |
| { | |
| it++; | |
| if (isCapicua(it)) | |
| { | |
| cout << it << ", "; | |
| contador++; | |
| } | |
| } | |
| capicua = it; | |
| return capicua; | |
| } | |
| int main() | |
| { | |
| cout << endl << capicua20() << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment