#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <list>
template <class InputIterator1, class InputIterator2>
bool myequal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
{
typename std::iterator_traits<InputIterator1>::difference_type len1 = std::distance(first1, last1);
typename std::iterator_traits<InputIterator2>::difference_type len2 = std::distance(first2, last2);
if (len1 != len2)
return false;
return std::equal(first1, last1, first2);
}
int main()
{
int a[] = {1, 10, 3, 5, 6, 5, 2, 9};
int b[] = {1, 10, 3, 5, 6, 5, 2};
size_t size_a = sizeof(a) / sizeof(a[0]);
size_t size_b = sizeof(b) / sizeof(b[0]);
bool eqb = myequal(a, a +size_a, b, b + size_b);
std::cout << "a[]とb[]は" << ((eqb) ? "等しい" : "等しくない") << std::endl;
eqb = myequal(b, b + size_b, a, a + size_a);
std::cout << "a[]とb[]は" << ((eqb) ? "等しい" : "等しくない") << std::endl;
std::vector<int> vi(a, a + size_a);
std::list<int> li(b, b + size_b);
eqb = myequal(vi.begin(), vi.end(), li.begin(), li.end());
std::cout << "viとliは" << ((eqb) ? "等しい" : "等しくない") << std::endl;
li.push_back(9);
eqb = myequal(vi.begin(), vi.end(), li.begin(), li.end());
std::cout << "viとliは" << ((eqb) ? "等しい" : "等しくない") << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxsaXN0PgoKdGVtcGxhdGUgPGNsYXNzIElucHV0SXRlcmF0b3IxLCBjbGFzcyBJbnB1dEl0ZXJhdG9yMj4KYm9vbCBteWVxdWFsKElucHV0SXRlcmF0b3IxIGZpcnN0MSwgSW5wdXRJdGVyYXRvcjEgbGFzdDEsIElucHV0SXRlcmF0b3IyIGZpcnN0MiwgSW5wdXRJdGVyYXRvcjIgbGFzdDIpCnsKICB0eXBlbmFtZSBzdGQ6Oml0ZXJhdG9y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