Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char sym;
  9.     int n, amount = 0;
  10.  
  11.     cout << "Enter size of string: ";
  12.     cin >> n;
  13.  
  14.     char *str = new char[n];
  15.     cout << "Enter string: ";
  16.     cin >> str;
  17.     cout << "Enter symbol: ";
  18.     cin >> sym;
  19.  
  20.     for (int i = 0; i < n; i++)
  21.     {
  22.         if (str[i] == sym) amount++;
  23.     }
  24.  
  25.     cout << "Amount: " << amount << endl;
  26.     _getch();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement