bug_ warning: control reaches end of non-void function
摘要
在leetcode上编译时,它显示我编译错误
warning: control reaches end of non-void function
它的意思是:控制到达非void函数的结尾。就是说你的一些本应带有返回值的函数到达结尾后可能并没有返回任何值。这时候,最好检查一下是否每个控制流都会有返回值。
错误原因
bool isPalindrome(int x) 是一个函数,但是我只在if里面加了返回值,没有在函数里加返回值,万一所以if都不成立呢?那么这个函数就没有输出了。这就是错误的原因
解决办法
只需在bool isPalindrome(int x) 最后加一个return 0;即可
源代码
这个代码只用作这个bug,作为回文数判断的话,这个代码是错误的
class Solution {
public:
bool isPalindrome(int x) {
int y,a;
if(x<)
return false;
else if (x==)
return false;
else if (<=x&x<)
return true;
while(x>){
y = x % ;
while(x>=)
a = x/;
if (a==y)
return true;
}
return ;
}
};
bug_ warning: control reaches end of non-void function的更多相关文章
- warning: control reaches end of non-void function
用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些 ...
- warning: control reaches end of non-void function 和 warning: implicit declaration of function 'rsgClearColor' is invalid in C99
用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些 ...
- 【gcc】warning: control reaches end of non-void function
用gcc编译一个C程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一 ...
- Control reaches end of non-void function 犯过最傻的错误
之所以会报“Control reaches end of non-void function ”的警告,时因为方法名中缺少返回类型.正确的写法如下: +(void)setMobile:(NSStrin ...
- error: control may reach end of non-void function [-Werror,-Wreturn-type]
编译出现如下错误 error: control may reach end of non-void function [-Werror,-Wreturn-type] 这个错误可能和编译器有关(在相同代 ...
- Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.
通过LR来录制登录过程并生成脚本,设置了自动关联,并回放录制脚本,观察回放日志发现没有报error信息,说明脚本没有问题,将脚本放入Controller中设置100个用户设置运行,发现运行一段时间开始 ...
- 【C/C++】C++ warning: control reaches end of non-void function return
控制到达非void函数的结尾. 一些本应带有返回值的函内数到容达结尾后可能并没有返回任何值. 这时候,最好检查一下是否每个控制流都会有返回值. 我是ostream声明的时候没有写return out; ...
- error:control reaches end of non-void function [-Werror=return-type]
在做LeetCode上的题目时,出现了这个错误, 原代码如下: class Solution { public: vector<int> twoSum(vector<int>& ...
- MFC中afx_msg是什么,afx_msg void function()是什么意思
应用程序框架产生的消息映射函数例如:afx_msg void OnBnClickedButton1(); 其中 afx_msg为消息标志,它向系统声明:有消息映射到函数实现体:而在map宏定义中,就有 ...
随机推荐
- @Autowired注解与@Resource注解的区别(详细)
相信对现在Java码农来说,@Autowired跟@Resource并不陌生,二者都可以自动注入,但是两者的区别很多时候并没有被注意到. 一.注解的出处 @Autowired是Spring提供的注解, ...
- rewrite例子集合
在 httpd 中将一个域名转发到另一个域名 虚拟主机世界近期更换了域名,新域名为 www.wbhw.com, 更加简短好记.这时需要将原来的域名 webhosting-world.com, 以及论坛 ...
- LeetCode 543. Diameter of Binary Tree 二叉树的直径 (C++/Java)
题目: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of ...
- linux messages日志出现kernel: nf_conntrack: table full, dropping packet
上述结果会让业务访问很慢!各种网络服务耗时大幅上升,各种time out,各种丢包,完全无法正常提供服务,大并发业务场景下,开防火墙很容易出现这种问题. 解决方法1:关闭分防火墙服务 解决方法2:修改 ...
- dbus探索
一.参考网址 1.Dbus组成和原理
- Codeforces Round #555 (Div. 3) B. Long Number 【仔细读题】
B. Long Number time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- springboot学习笔记:8. springboot+druid+mysql+mybatis+通用mapper+pagehelper+mybatis-generator+freemarker+layui
前言: 开发环境:IDEA+jdk1.8+windows10 目标:使用springboot整合druid数据源+mysql+mybatis+通用mapper插件+pagehelper插件+mybat ...
- 剑指offer【10】- 变态跳台阶
题目:一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 关于本题,前提是n个台阶会有一次n阶的跳法.分析如下: f(1) = 1 f(2) ...
- tensorflow(七)
一.模型托管工具 TensorFlow Serving TensorFlow Serving支持生产级的服务部署,允许用户快速搭建从模型训练到服务发布的工作流水线. 工作流水线主要由三部分构成 (1) ...
- MySQL报错解决:The MySQL server is running with the --read-only option so it cannot execute this statement
MySQL报错:The MySQL server is running with the --skip-grant-tables option so it cannot execute this st ...