Advertisement
35657

Untitled

Apr 20th, 2024
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.    
  9.     SetConsoleCP(1251);
  10.     SetConsoleOutputCP(1251);
  11.    
  12.     char line[100];
  13.  
  14.     cout << "Введите строку: ";
  15.     gets_s(line);
  16.  
  17.     int m, n;
  18.  
  19.     cout << "Введите m: ";
  20.     cin >> m;
  21.     cout << "Введите n: ";
  22.     cin >> n;
  23.  
  24.     char* result = new char[strlen(line) - (n - m)];
  25.  
  26.     int k = 0;
  27.     for (int i = 0; i < m; i++, k++) {
  28.         result[k] = line[i];
  29.     }
  30.     for (int i = n + 1; i < strlen(line); i++, k++) {
  31.         result[k] = line[i];
  32.     }
  33.     result[k] = '\0';
  34.  
  35.     cout << result << endl;
  36.     delete[] result;
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement