Advertisement
35657

Untitled

Apr 20th, 2024
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 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 num;
  18.  
  19.     cout << "Введите индекс символа: ";
  20.     cin >> num;
  21.    
  22.     if (num < 0 || num >= strlen(line)) {
  23.         cout << "Некорректный индекс" << endl;
  24.         return 0;
  25.     }
  26.  
  27.     for (int i = num; i < strlen(line); i++) {
  28.         line[i] = line[i + 1];
  29.     }
  30.  
  31.     cout << line;
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement