
identificar numeros palíndromo en c
Publicado por nn (4 intervenciones) el 28/09/2020 03:35:03
programa para identificar si un numero ingresado por un usuario es palíndromo en c
Valora esta pregunta


-2
#include <iostream>
#include <string>
using namespace std;
int main()
{
int numero;
cout << "\nnumero: "; cin >> numero;
string s = to_string(numero);
int i = 0, k = s.length() - 1;
bool esPalindromo = true;
while (i < k)
{
if (s[i++] != s[k--])
{
esPalindromo = false;
break;
}
}
cout << endl;
if (!esPalindromo)
cout << "No ";
cout << "Es palindromo" << endl;
return 0;
}