fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main() {
  9. const size_t n = 5;
  10.  
  11. int nomer1[n] = {0, 1, 2, 3, 4};
  12. int nomer2[n] = {2, 4, 6, 7, 8};
  13. int nomer3[n] = {0, 1, 2, 3, 4};
  14.  
  15. if (memcmp(&nomer1, &nomer2, sizeof(int)*n)==0)
  16. cout << "Equal 1 & 2 by memcmp" << endl;
  17.  
  18. if (memcmp(&nomer1, &nomer3, sizeof(int)*n)==0)
  19. cout << "Equal 1 & 3 by memcmp" << endl;
  20.  
  21. if (equal(nomer1, nomer1 + n, nomer2))
  22. cout << "Equal 1 & 2 by equal" << endl;
  23.  
  24. if (equal(nomer1, nomer1 + n, nomer3))
  25. cout << "Equal 1 & 3 by equal" << endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
Equal 1 & 3 by memcmp
Equal 1 & 3 by equal