TOPIC

Wrong Answer 20%

JVMDO asked 3 years ago

Podem me dar algum caso de teste que não passe corretamente?

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<char> letters;
    string sentence;
    int t, p;

    while( getline( cin, sentence ) ){
        for( int i = 0; i < sentence.size(); i++ )
            if( sentence[i] >= 'A' && sentence[i] <= 'Z' )
                sentence[i] += 32;

        for( int i = 0; i < sentence.size(); i++ )
            if( sentence[i] != ' ' ){
                letters.push_back( sentence[i] );
                p = i+1;
                break;
            }

        for( int i = p; i < sentence.size(); i++ )
            if( sentence[i] == ' ' )
                letters.push_back( sentence[i+1] );

//        for( char it : letters )
//            cout << it << " ";

        t = 0;
        for( short k = 1; k < letters.size(); k++ )
            if( letters[k+1] != letters[k] && letters[k-1] == letters[k] )
                t++;

        letters.clear();
        cout << t << endl;
    }

    return 0;
}

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

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