7.06.2017

완전 동일 배열

//C++로 시작하는 객체지향 프로그래밍 p.330 예제 7.20 - 완전 동일 배열
#include <iostream>
using namespace std;

bool strictlyEqual(const int list1[], const int list2[], int size) {
for (int k = 0; k < size; k++){
if (list1[k] != list2[k])
return false;
return true;
}
}

int main() {
const int SIZE = 20;
int list1[SIZE];
cout << "Enter list1: ";
int size1;
cin >> size1;

for (int i = 0; i < size1; i++){
cin >> list1[i];
}

cout << "Enter list2: ";
int list2[SIZE];
int size2;
cin >> size2;
for (int j = 0; j < size2; j++){
cin >> list2[j];
}

if (size1 == size2 && strictlyEqual(list1, list2, size1))
cout << "Two lists are strictly identical" << endl;
else cout << "Two lists are not strictly identical" << endl;


system("pause");
return 0;
}

댓글 없음:

댓글 쓰기