#define _SCL_SECURE_NO_WARNINGS 1 // Turn off Microsoft Error/Warning
#include <algorithm>
#include <iostream>
int main()
{
int sequence1[8] = {1, 3, 2, 4, 5, 7, 6, 8};
int sequence2[8] = {1, 3, 2, 4, 5, 7, 6, 8};
int sequence3[8] = {1, 3, 2, 4, 5, 7, 6, 1};
std::cout << std::equal(&sequence1[0], &sequence1[8], &sequence2[0]) << " ";
std::cout << std::equal(&sequence1[0], &sequence1[8], &sequence3[0]) << " ";
std::cout << std::endl;
return 0;
}
// Output: 1 0
Reference: Josuttis, Nicolai M., The C++ Standard Library: A Tutorial and Reference. New York: Addison-Wesley, 1999, p. 101.
Tuesday, December 19, 2017
C++98: std::Equal()
The template function std::Equal() compares two sequences. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment