36. else if 多分支
语法讲解
今天学: else if 可以添加更多条件分支。
#include <iostream>
using namespace std;
int main() {
int x = 0;
if (x > 0) {
cout << "positive" << endl;
} else if (x == 0) {
cout << "zero" << endl;
} else {
cout << "negative" << endl;
}
return 0;
}
小练习
输出是什么?
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论