TOPIC

25% de erro em C++

Renato Moran asked 2 years ago

#include <iostream>

using namespace std;

int main()
{
    string frase;
    int diferenca = 0;;
    bool ok = true;
    int tam = 0;
    int aux = 0;

    while( getline(cin,frase) ){

        tam = frase.size();
        //tam++;

        while( aux <= tam ){

            for (int i = aux, j = tam - 1 ; i <=  tam - 1 ; i++, j--){

                if( frase[i] == frase[j] ){
                    diferenca++;
                    ok = true;
                }else{
                    ok = false;
                    break;
                }
            }

            if( ok == true ){
                break;
            }
            aux++;

        }

        cout << ( tam - diferenca ) << endl;
        diferenca = 0;

    }

    return 0;
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.