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

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

在这里插入图片描述

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

猜你喜欢

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