实例 C++ else 语句

x
 
#include <iostream>
using namespace std;
int main() {
  int time = 20;
  if (time < 18) {
    cout << "Good day.";
  } else {
    cout << "Good evening.";
  }
  return 0;
}
                    

输出结果

Good evening.