Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- char palabra[100], pal[100];
- cout << "Numero de letras que tiene la palabra: ";
- cin >> n;
- cout << endl << "Palabra: ";
- for(int i = 1; i <= n; i++)
- {
- cin >> palabra[i];
- }
- int temp;
- int c = n;
- for(int i = 1; i <= n; i++)
- {
- pal[i] = palabra[i];
- }
- for(int i = 1; i <= n; i++)
- {
- temp = pal[i];
- pal[i] = pal[c];
- pal[c] = temp;
- c--;
- }
- cout << endl;
- bool found = false;
- for(int i = 1; i <= n; i++)
- {
- if(pal[i] != palabra[n]){
- found = true;
- }
- n--;
- }
- if(found == false)
- {
- cout << "Es un palindromo" << endl;
- } else
- {
- cout << "No es un palindromo" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement