Vla_DOS

3

Jul 2nd, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(0, "");
  8.     int n = 0, a = 0, d = 0;
  9.     cout << "Введiть розмiр масиву: ";
  10.     cin >> n;
  11.     int* arr = new int[n];
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         arr[i] = rand() % 27;
  15.     }
  16.     for (int i = 0; i < n; i++) {
  17.         cout << arr[i] << "\t";
  18.     }
  19.  
  20.     int element;
  21.     cout << "\nВведiть елемент для пошуку: ";
  22.     cin >> element;
  23.     int count = 0;
  24.     for (int i = 0; i < n; i++) {
  25.         if (arr[i] == element) {
  26.             count++;
  27.         }
  28.  
  29.     }
  30.  
  31.     cout << "\nЕлементiв " << element << " = " << count << endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment