Untitled
unknown
plain_text
a year ago
1.1 kB
3
Indexable
Never
#include <iostream> #include <vector> void sortVector(std::vector<int>& vec) { // write your code here static_cast<void>(vec); } void check(const std::vector<int>& actual, const std::vector<int>& expected); int main() { std::vector<int> v = {5, 16, 2, 75, 43, 8, 43, 56, 21, 11, 60}; sortVector(v); check(v, {2, 5, 8, 11, 16, 21, 43, 43, 56, 60, 75}); v = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; sortVector(v); check(v, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}); v = {5, 16}; sortVector(v); check(v, v); v = {}; sortVector(v); check(v, v); v = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; sortVector(v); check(v, v); return 0; } void check(const std::vector<int>& actual, const std::vector<int>& expected) { if (std::equal(actual.begin(), actual.end(), expected.begin())) { std::cout << "SUCCESS!" << std::endl; } else { std::cout << "FAIL!" << std::endl; for (const auto& item : actual) { std::cout << item << " "; } std::cout << std::endl; } }