Advertisement
35657

Untitled

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