这个代码和你想的结果相反是为什么

这个代码和你想的结果相反是为什么

#include

using namespace std;

void d(void){
unsigned int a=8;int b = -20;
(a = b>8)?put(">8"):puts("<=8");
}

答案:>8
原因:当表达式中存在有符号类型和无符号类型时所有的操作数都会自动转换成无符号数。

猜你喜欢

转载自blog.csdn.net/m0_46376834/article/details/106870584
今日推荐