- #include <iostream>
- using namespace std;
- void convert(char *str ,char *substr)
- {
- int lenstr = strlen(str);
- int lensubstr = strlen(substr);
- while(lenstr >= 1)
- {
- while (str[--lenstr] != substr[lensubstr-1] && lenstr >= 0)
- cout<<str[lenstr];
- int ls = lenstr;
- int issub = 0;
- while(str[lenstr] == substr[lensubstr-1-issub] && issub < lensubstr )
- {
- issub++;
- lenstr--;
- }
- if (issub == lensubstr)
- for(int i = 0 ; i < lensubstr ; i++)
- cout<<substr[i];
- else
- {
- lenstr = ls;
- for(int i = 0 ; i < issub ;i++)
- cout<<str[lenstr--];
- }
- lenstr++;
- }
- cout<<endl;
- }
- void main()
- {
- convert("This is my books ! And the is yours? Right? Yes!!","is");
- }