Numeros Palindromos o Capicuas
Alguien dispone de un algoritmo sencillo en c/c++ que genere NUMEROS Palindromos o Capicuas ?
Muchas Gracias.
Muchas Gracias.
Te envio un programa que genera numeros capicuas.
Si te intereza algo mas complicado, tambien te lo puedo enviar.
// programa capicuas.cpp
// written in Borland CPP ver 4.5
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <conio.h>
void Reversar(int a,int &b)
{
if(a)
{
b = 10*b + a%10;
Reversar(a/10,b);
}
} // REVERSAR
void main()
{
randomize();
for(int i = 1;i <= 20;i++)
{
long a = random(9000)+1000;
int b = 0;
Reversar(a,b);
a = a*10000 + b;
cout << setw(5) << i << " : " << a << endl;
}
cout << endl << "end of program - good bye ! ! ! " << endl;
} // MAIN
Si te intereza algo mas complicado, tambien te lo puedo enviar.
// programa capicuas.cpp
// written in Borland CPP ver 4.5
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <conio.h>
void Reversar(int a,int &b)
{
if(a)
{
b = 10*b + a%10;
Reversar(a/10,b);
}
} // REVERSAR
void main()
{
randomize();
for(int i = 1;i <= 20;i++)
{
long a = random(9000)+1000;
int b = 0;
Reversar(a,b);
a = a*10000 + b;
cout << setw(5) << i << " : " << a << endl;
}
cout << endl << "end of program - good bye ! ! ! " << endl;
} // MAIN
