jeudi 27 août 2020

Process was terminated. It took longer than 12000ms to complete

Create a function that takes a sentence and turns every "i" into "wi" and "e" into "we", and add "owo" at the end.

I was creating the function for the above question and received an error:

Process was terminated. It took longer than 12000ms to complete

Can anyone please help me with the fix?

#include<string>

std::string owofied(std::string sentence) {
    int pos=0;
    for(int i =0 ; i<sentence.size(); i++)
    {
        if(sentence[i]=='i')
            sentence.replace(i,1,"wi");
        else if(sentence[i]=='e')
            sentence.replace(i,1,"we");
        pos=i;
    }
    sentence.insert(pos,"owo");
    return sentence;
}

Aucun commentaire:

Enregistrer un commentaire