RicoHeartless

Laba 1.2 (2K)

Sep 18th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <Windows.h>
  4.  
  5. using namespace std;
  6.  
  7. void revSubStr(char* text){
  8.     char *oldtext = new char[100];
  9.     char enter_id;
  10.     char* end_id = new char[1];
  11.     cout << "Enter position #1: ";
  12.     cin >> enter_id;
  13.     cout << "Enter position #2: ";
  14.     cin >> end_id;
  15.     for (int i(0); i <= strlen(text); i++)
  16.     {
  17.         oldtext[i] = text[i];
  18.     /*  if (strchr(oldtext, enter_id) == NULL)
  19.         {
  20.             cout << "ERROR! NO SUCH THING AS '" << enter_id << "' IN SENTENSE!"<<endl;
  21.             exit(0);
  22.         }*/
  23.     }
  24.     char* a1 = strchr(text, enter_id);
  25.     cout << "text: " << text << endl;
  26.     char* a3 = strtok(a1, end_id);
  27.     char* a4 = strcat(a3, end_id);
  28.     int index = strcspn(text, a4);
  29.     int riz = strcmp(a1, text) + index;
  30.     char* reverse = strrev(a4);
  31.     int lenght = strlen(oldtext);
  32.     for (int i(0); i < strlen(reverse); i++)
  33.     {
  34.         oldtext[index + i] = reverse[i];
  35.  
  36.     }
  37.     cout << "result end : " << oldtext << endl;
  38.     delete[] oldtext, end_id;
  39. }
  40.  
  41. void main()
  42. {
  43.     const char n = 100;
  44.     char text[n];
  45.     cout << "Enter string: ";
  46.     cin.getline(text, 100);
  47.     revSubStr(text);
  48. }
Add Comment
Please, Sign In to add comment