Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
122
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. using namespace std;
  3.  
  4. int main()
  5. {
  6.     setlocale(LC_ALL, "Russian");
  7.     cout << "Введите количество элементов массива" << endl;
  8.     int N;
  9.     cin >> N;
  10.     int* a = new int[N];
  11.     int count = 0;
  12.     int x;
  13.     cout << "Введите число" << endl;
  14.     cin >> x;
  15.     for (int i = 0; i < N; i++) {
  16.         cout << "Введите элемент" << endl;
  17.         cin >> a[i];
  18.     }
  19.     for (int i = 0; i < N; i++){
  20.         if (a[i] == x){
  21.             count = 1;
  22.         }
  23.     }
  24.     if (count == 1) {
  25.         cout << "В массиве есть как минимум одно такое число, как " << x << endl;
  26.     }
  27.     else
  28.         cout << "Нет таких чисел";
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement