Advertisement
35657

Untitled

Apr 20th, 2024
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 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.     char ch;
  18.  
  19.     cout << "Введите символ: ";
  20.     cin >> ch;
  21.    
  22.     for (int i = 0; i < strlen(line); i++) {
  23.         if (line[i] == ch) {
  24.             cout << i + 1 << " ";
  25.         }
  26.     }
  27. }
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement