//带符号减法溢出判断
#include<iostream>
using namespace std;
int sun_ok(int x,int y)
{
int diff=x+~y+1;
int x_neg=x>>31;
int y_neg=y>>31;
int d_neg=diff>>31;
return !(~(x_neg^~y_neg)&&(x_neg^d_neg));
}
int main()
{
int x,y;
cin>>x>>y;
if(sun_ok(x,y))
cout<<"不溢出";
else
cout<<"溢出";
return 0;
}
编程实现 带符号减法溢出判断
猜你喜欢
转载自blog.csdn.net/weixin_45884316/article/details/105141593
今日推荐
周排行