35657

Untitled

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