-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.36a.cpp
56 lines (52 loc) · 986 Bytes
/
3.36a.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
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <iterator>
#include <cstddef> // size_t and ptrdiff_t
using std::end;
using std::begin;
using std::cout;
using std::endl;
using std::cin;
int main() {
constexpr size_t sz = 8;
int arr1[sz] = {};
int *p1 = begin(arr1), *p2 = end(arr1);
int num;
cout << "First array" << endl;
while (p1 != p2) {
if (cin >> num) {
*p1 = num;
++p1;
}
}
cout << "Second array" << endl;
int arr2[sz] = {};
p1 = begin(arr2);
p2 = end(arr2);
while (p1 != p2) {
if (cin >> num) {
*p1 = num;
++p1;
}
}
cout << endl;
for (const int &i : arr1) {
cout << i << " ";
}
cout << endl;
for (const int &i : arr2) {
cout << i << " ";
}
cout << endl;
p1 = begin(arr1);
p2 = begin(arr2);
while (p1 != end(arr1) && p2 != end(arr2) && *p1 == *p2) {
++p1;
++p2;
}
if (p1 == end(arr1) && p2 == end(arr2)) {
cout << "The two arrays don't differ" << endl;
} else {
cout << "The two arrays differ from each other" << endl;
}
return 0;
}