社区讨论

about Lambda 表达式

学术版参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@m0annc2p
此快照首次捕获于
2024/08/26 15:06
2 年前
此快照最后确认于
2025/11/04 22:23
4 个月前
查看原帖
它没法递归吗?
CPP
auto dfs = [&](int x, int y) -> int {
	    if (f[x][y]) return f[x][y];
	    f[x][y] = 1;
	    for (int i = 1; i <= 4; ++ i)
	    {
	        int tx = x + dx[i];
	        int ty = y + dy[i];
	        if (tx >= 1 && tx <= n && ty >= 1 && ty <= m && mp[tx][ty] < mp[x][y])
	            f[x][y] = max(f[x][y], dfs(tx, ty) + 1);
	    }
	    return f[x][y];
	};
他要报错
CPP
27	37	C:\Users\Lenovo\Documents\a.cpp	[Error] use of 'dfs' before deduction of 'auto'
27	37	C:\Users\Lenovo\Documents\a.cpp	[Error] use of 'main()::<lambda(int, int)>::<dfs capture>' before deduction of 'auto'
27	47	C:\Users\Lenovo\Documents\a.cpp	[Error] 'dfs' cannot be used as a function

回复

2 条回复,欢迎继续交流。

正在加载回复...