35657

Untitled

Jan 20th, 2024
573
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_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <Windows.h> // нужна для работы SetConsole
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10. int main() {
  11.  
  12.     SetConsoleCP(1251); // установка кодировки 1251 в поток ввода
  13.     SetConsoleOutputCP(1251); // установка кодировки 1251 в поток вывода (то же, что setlocale)
  14.  
  15.     char line[40];
  16.     int m;
  17.  
  18.     cout << "Введите строку: ";
  19.     gets_s(line);
  20.     cout << "Введите индекс символа: ";
  21.     cin >> m;
  22.  
  23.     if (m < 0 || m >= strlen(line)) {
  24.         cout << "Такого символа нет";
  25.         return 0;
  26.     }
  27.  
  28.     for (int i = m; i < strlen(line); i++) {
  29.         line[i] = line[i + 1];
  30.     }
  31.  
  32.     cout << line;
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment