编程实现 无符号减法溢出判断

//无符号减法溢出判断  
#include<iostream>
using namespace std;
int usub_ok(unsigned x,unsigned y)
{
        unsigned diff = x - y;
        return diff <= x;
}
int main()
{
	unsigned int x,y;
	cin>>x>>y;
	if(usub_ok(x,y))
		cout<<"不溢出";
	else
		cout<<"溢出";
	return 0;
 } 

在这里插入图片描述

发布了164 篇原创文章 · 获赞 440 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_45884316/article/details/105141505
今日推荐