Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4. int main() {
  5.     int size;
  6.     int x, n=0;
  7.     srand(time(NULL));
  8.     setlocale(LC_ALL, "rus");
  9.     cout << "Введите размер массивов - ";
  10.     cin >> size;
  11.     cout << "Введите x - ";
  12.     cin >> x;
  13.     int* A = new int[size];
  14.     int* B = new int[size];
  15.     cout << "Массив А :" << endl;
  16.     for (int i = 0; i < size; i++) {
  17.         A[i] = rand() % 50;
  18.         cout << A[i] << ' ';
  19.         if (A[i] < x)n++;
  20.     }
  21.     cout << "Массив B :" << endl;
  22.     for (int i = 0; i < size; i++) {
  23.         B[i] = rand() % 50;
  24.         cout << B[i] << ' ';
  25.         if (B[i] < x)n++;
  26.  
  27.     }
  28.     cout <<endl<<"Количество элементов меньше х : " <<n;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement