Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2014, 18:55
andresbarreto18
 
Fecha de Ingreso: octubre-2014
Mensajes: 3
Antigüedad: 9 años, 6 meses
Puntos: 0
Pregunta c++, no me sale bien el resultado si es palindromo o no

Código C++:
Ver original
  1. #include<iostream>
  2. #include <string.h>
  3. #include<stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.            char frase[30];
  9.            int tam,i;
  10.            bool band= true;
  11.            char resp[20];
  12.            cout<<"ingresa la frase: ";
  13.            gets(frase);
  14.            tam=strlen(frase)-1;
  15.            while(i<tam&&band){
  16.            if(frase[i]==frase[tam]){
  17.             i++;
  18.             tam--;
  19.            }else{
  20.            band= false;
  21.            }
  22.            }
  23.            if(i>tam){
  24.     strcpy(resp,"si es palindromo");
  25.     }else{
  26.     strcpy(resp,"no es palindromo");
  27.     }
  28.     cout<<resp;
  29. }