//带符号加法溢出判断
#include<iostream>
using namespace std;
int tadd_ok(int x,int y)
{
int sum=x+y;
int neg_over=x<0&&y<0&&sum>=0;
int pos_over=x>=0&&y>=0&&sum<0;
return !neg_over&&!pos_over;
}
int main()
{
int x,y;
cin>>x>>y;
if(tadd_ok(x,y))
cout<<"不溢出";
else
cout<<"溢出";
return 0;
}
编程实现 带符号加法溢出判断
猜你喜欢
转载自blog.csdn.net/weixin_45884316/article/details/105141551
今日推荐
周排行