Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created August 31, 2015 18:17
Show Gist options
  • Select an option

  • Save codepainkiller/ea7cb626c7dcf7c40045 to your computer and use it in GitHub Desktop.

Select an option

Save codepainkiller/ea7cb626c7dcf7c40045 to your computer and use it in GitHub Desktop.
20vo numero capicua
#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