c++的lamda表达式

作用:

弥补了main函数里面不可以定义函数的缺陷,减少了全局变量的声明

可以在main里面搭建小的构件,如下:

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
#define loop(n) for(int i=0;i<n;i++)
#define rloop(n) for(int i=n-1;i>=0;i--)
#define print(c) cout<<"this "#c" is "<<c<<endl;
#define MAX INT_MAX
#define MIN INT_MIN
const int N = 1010;

using namespace std;
void solve() {
    int n = 10;
    int a[10] = { 1,2,3,4,5,6,7,7,8,9 };
    auto check = [&](int j, int i) {//用来查重
        map<int, int> m;
        for (; j <= i; j++)
            if (m[a[j]] == 1)return 0;
            else m[a[j]]++;
        return 1;
        };
    auto f1 = [&]() {//用于返回最大的不重复子序列
        int count = 0;//窗口长度
        for (int i = 0,j=0; i < n; i++) {
            if (
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值