[LeetCode] error:control reaches end of non-void function[-Werror=return-type]

刷 LeetCode 题库时,出现如上报错,代码没问题,本地运行也没问题,可复制到 LeetCode 就报错。

解决方案:在函数的最后添加一条 return 语句,只要返回的类型对即可!(return 0 也行)。

切记:一定要返回,虽然永远也用不上。

参考 https://blog.csdn.net/FunnyZilly/article/details/87899960

原文地址:https://www.cnblogs.com/xiangsui/p/11546981.html