Advertisement
35657

Untitled

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