-
Notifications
You must be signed in to change notification settings - Fork 0
/
slianie2mas.cpp
45 lines (40 loc) · 998 Bytes
/
slianie2mas.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "time.h"
#include "iostream"
using namespace std;
void arr(int* arr_1,int n, int* arr_2, int m)
{
cout << "Equals elements in two array: " <<endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (*(arr_1 + i) == *(arr_2 + j))
cout << *(arr_1 + i) << " ";
}
}
cout << endl;
}
int main()
{
int n, m;
srand(time(0));
n = rand() % 20 + 10;
m = rand() % 20 + 10;
int* arr_1 = (int*)malloc(n*sizeof(int));
int* arr_2 = (int*)malloc(m*sizeof(int));
cout << "First array (size = " << n << " ): " << endl;
for (int i = 0; i < n; i++)
{
*(arr_1+i) = rand() % 20 - 10;
cout << *(arr_1 + i) << " ";
}
cout <<endl<<"Second array (size = " << n << " ): " << endl;
for (int i = 0; i < n; i++)
{
*(arr_2 + i) = rand() % 20 - 10;
cout << *(arr_2 + i) << " ";
}
cout << endl;
arr(arr_1,n,arr_2,m);
return 0;
}