Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string>
- #include <string.h>
- using namespace std;
- char* fun(char *a, char *b, int n)
- {
- string a_str, b_str(b), ans(a);
- int p = 0;
- for (int i = 0; i < n - 1; i++)
- {
- int count = 0, it;
- a_str = ans;
- while ((p = a_str.find('X')) != string::npos)
- {
- a_str[p] = '#';
- it = p + (b_str.size() - 1)*count;
- ans.insert(it + 1, b_str);
- ans.erase(it, 1);
- count++;
- }
- }
- char * str = new char[ans.size() - 1];
- strcpy(str, ans.c_str());
- return str;
- }
- int main()
- {
- char a[200]="F+XF+F+XF", b[200]="XF-F+F-XF+F+XF-F+F-X";
- printf("%s", fun(a, b, 2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement