Varianta 78 / Subiectul 2 / Problema 5 |
#include<string.h> #include<iostream.h> void main() { char s1[200], s2[15], *p, aux[200]; int cont=0; cin.get(s1,200); cin.get(); cin>>s2; p=s1; while(strstr(p,s2)) { char *q=strstr(p,s2); if(((q-1)[0]==' ' || p==s1) && (q+strlen(s2))[0]==' ') { char aux[200]; strcpy(aux,s2); strcat(aux,"?"); strcat(aux,q+strlen(s2)); strcpy(q,aux); cont=1; } p=q+strlen(s2); } if(cont) cout<<s1; else cout<<"nu exista"; } |