📄 prog4_07.cpp
字号:
// Program 4.7 Using the conditional operator to select output.
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main() {
int mice = 0; // Count of all mice
int brown = 0; // Count of brown mice
int white = 0; // Count of white mice
cout << "How many brown mice do you have? ";
cin >> brown;
cout << "How many white mice do you have? ";
cin >> white;
mice = brown + white;
cout << "You have "
<< mice
<< (mice == 1 ? " mouse " : " mice ")
<< "in total."
<< endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -