35657

Untitled

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