Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- char* str1=new char[12];
- char* str2=new char[10];
- char *temp1=new char[20];
- char* temp2 = new char[20];
- char* temp3 = new char[20];
- char* temp4 = new char[20];
- *temp4 = 0;
- char* temp5 = new char[20];
- *temp5 = 0;
- char* temp6 = new char[20];
- *temp6 = 0;
- char* symbol = new char;
- int n;
- cout << "Enter str1: " << endl;
- cin >> str1;
- cout << "Enter str2: " << endl;
- cin >> str2;
- cout << "Enter symbol: " << endl;
- cin >> symbol;
- cout << "Enter n: " << endl;
- cin >> n;
- strcpy(temp5, str1);
- strcpy(temp6, str2);
- temp1 = _strrev(temp5);
- temp1 = strstr(temp1, symbol);
- temp1 = _strrev(temp1); //здесь строка уже прямая с символом на конце
- temp2= _strrev(temp6);
- temp2 = strtok(temp2, symbol);//берем из реверсной строки подстроку до символа без него
- temp2=_strrev(temp6);//обратно
- strncat(temp1, temp2, n);//соединяем
- if (strlen(temp2) + 1 < n)
- {
- int i = strlen(str1) - strlen(temp1);
- cout << i << endl;
- temp3 = _strrev(str1);
- strncat(temp4, temp3, i);
- temp4 = _strrev(temp4);
- strncat(temp1, temp4, i);
- }
- printf("%s", temp1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement