lundi 25 juin 2018

there is a mistake in my code but i can't see it

i try to apply this code to my teacher but he said this code was wrong. i don't know what's wrong with it.

a=contain b in it. d=next to the c.

example for the input: abcdehellofghi bcd <---removed from the first line hello world <--- added to the first line next to "hello".

example for the output: aehelloworldfghi

#include <iostream>
using namespace std;

int main(){
string a,b,c,d;
int x,y,z,l=0,w,v,t,p=0,q[100],o[100];

cin >> a >> b >> c >> d;

y=a.length()-1;
z=b.length()-1;
v=c.length()-1;

for(x=0;x<=y;x++){
    if(a[x]==b[0]){
        for(w=0;w<=z;w++){
            if(a[x]==b[w]){
                q[w]=x;
                x++;
            }
        }break;
    }
}

for(x=0;x<=y;x++){
    if(a[x]==c[l]){
        for(w=0;w<=v;w++){
            if(a[x]==c[w]){
                o[w]=x;
                x++;
                t=x-1;
            }
        }break;
    }
}


for(x=0;x<=y;x++){
    if(q[p]==x){
        p++;
        continue;
    }else if(t!=x){
        cout << a[x];
    }else if(t==x){
        cout << a[x];
        cout << d;
    }
}cout << endl;
}

Aucun commentaire:

Enregistrer un commentaire