• 使用vc2010的c++0x特性,我们可以写出简洁有趣的代码


    #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的快捷手感了。

  • 相关阅读:
    杂记5
    杂记4
    杂记3
    杂记2
    杂记1
    也来个网页版本的五子棋
    验证码识别
    npm publish命令
    window nginx php ci框架环境搭建
    也来个网页版本的五子棋
  • 原文地址:https://www.cnblogs.com/oiramario/p/1847812.html
Copyright © 2020-2023  润新知