64,680
社区成员
发帖
与我相关
我的任务
分享
#include <iostream> // 数据流输入/输出
#include <algorithm> // STL 通用算法
#include <vector> // STL 动态数组容器
using namespace std;
int main()
{
// lambda函数
[] { cout << "Hello, my Greek friends\n"; }();
auto func = [](int i) { while(i--) cout << "Hello world\n"; };
func(5); // now call the function 打印5行
vector<int> v = {32, 871, 412, 45, 26, 80, 53, 33};
sort(v.begin(), v.end(), [](int i , int j) { return (i > j); });
for_each(v.begin(), v.end(), [](int val) { cout << val << endl; });
return 0;
}
Hello, my Greek friends
Hello world
Hello world
Hello world
Hello world
Hello world
871
412
80
53
45
33
32
26
Process returned 0 (0x0) execution time : 0.016 s
Press any key to continue.
auto func = [](int i) { while(i--) cout << "Hello world\n"; };//好久没来csdn了,我out了?