TOPIC

100% wrong answer

[C]-Lomazzi-Fernando-UTN FRSF 2020-AEDD asked 3 months ago

Oi, eu nao comprendo pq meu codigo brinda-me 100% do error. Eu preciso de respostas. VLW manitos.

include

using namespace std;

int main(int argc, char *argv[]) {

string n;

cin >> n;

for(unsigned i=0;i<n.size();i++){

    for(unsigned j=0;j<n.size()-1;j++){

        if(j<n.size()-2 and n[j]=='7' and n[j+1]=='3' and n[j+2]=='5'){

            n[j]='5';n[j+1]='7';n[j+2]='3';

        }

        if(n[j]>n[j+1] and (n[j]=='5' or n[j+1]=='5')){

            char aux=n[j];

            n[j]=n[j+1];

            n[j+1]=aux;
        }
    }
}

cout << n << endl;

return 0;

}

This topic was solved and cannot recieve new replies.

  • feodorv replied 3 months ago

    You can consider the following input:

    77773335

    You solution prints

    77773335

    while the correct answer is

    57777333