鱼C论坛

 找回密码
 立即注册
查看: 907|回复: 1

为什么改为auto会报错得这样写才对

[复制链接]
发表于 2024-2-26 21:02:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include <bits/stdc++.h>
  2. using namespace std;

  3. int main() {
  4.     string instr, poststr;
  5.     cin >> instr >> poststr;
  6.    
  7.     auto build = [&](string instr, string poststr) { //为什么改为auto会报错得这样写才对function<void(string,string)>build=[&](string instr,string poststr)
  8.         if(instr.size() <= 0) return;
  9.         
  10.         cout << poststr.back();
  11.         int mid = instr.find(poststr.back());
  12.         
  13.         build(instr.substr(0, mid), poststr.substr(0, mid));
  14.         build(instr.substr(mid + 1), poststr.substr(mid, poststr.size() - instr.size() + mid));
  15.     };
  16.    
  17.     build(instr, poststr);
  18.    
  19.     return 0;
  20. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-7 02:52

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表