#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <vector>
#include <iterator>

int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vec;
int sz[] = {1, 7, 4, 2};
std::copy(sz, sz + 4, std::back_inserter(vec));

std::for_each(sz, sz + 4, [](int n){ std::cout << n << " "; });
std::cout << std::endl;

std::sort(vec.begin(), vec.end(), [](int x, int y) { return x < y; });
std::for_each(vec.begin(), vec.end(), [](int n){ std::cout << n << " "; });

std::cout << std::endl;

std::sort(vec.begin(), vec.end(), [](int x, int y) { return x > y; });
for (auto itor = vec.begin(); itor != vec.end(); ++itor)
std::cout << *itor << " ";

return 0;
}

c++0x整合了一些boost的东西,c++终于也可以拥有script language的快捷手感了。

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-01-10
  • 2021-06-19
  • 2022-01-10
相关资源
相似解决方案