forked from chihyang/CPP_Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer03_36_1.cpp
More file actions
31 lines (31 loc) · 748 Bytes
/
Copy pathExer03_36_1.cpp
File metadata and controls
31 lines (31 loc) · 748 Bytes
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
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int a1[0];
int a2[0]; // Be sure the program doesn't crash under any circumstance.
int a1len = sizeof(a1) / sizeof(int);
int a2len = sizeof(a2) / sizeof(int);
cout << a1len << " " << a2len << endl;
if(a1len == a2len)
{
for(int i = 0; i < a1len; ++i)
{
cout << a1[i] << " " << a2[i] << endl;
if(a1[i] != a2[i])
{
cout << "a1 and a2 are NOT equal!" << endl;
return -1;
}
}
cout << "a1 and a2 are equal!" << endl;
}
else
{
cout << "a1 and a2 are NOT equal!" << endl;
return -1;
}
return 0;
}