写出与表达式z = x=y x y 等价的if语句并上机验证。
if (x >= y) { z = x; } else { z = y; }
验证代码:
#include
int main() { int x = 5; int y = 3; int z = (x >= y ? x : y);
cout << "z = " << z << endl;
if (x >= y) {
z = x;
} else {
z = y;
}
cout << "z = " << z << endl;
return 0;
}
输出:
z = 5 z = 5
原文地址: https://www.cveoy.top/t/topic/Nhu 著作权归作者所有。请勿转载和采集!