C++ Primer 第四版课后练习解答 习题1.16

注意:本随笔是在《C++Primer(第四版)习题解答(完整版)》中直接抄录的。此处主要是便于本人以后反复阅读。

习题1.16

编写程序,输出用户输入的两个数中的较大者。

【解答】

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     cout << "Enter two numbers:" << endl;
 7     int val1, val2;
 8     cin >> val1 >> val2;
 9     if (val1 >= val2)
10         cout << "The bigger number is " << val1<<endl;
11     else
12         cout << "The bigger number is " << val2<<endl;
13 
14     return 0;
15 }

 

posted @ 2017-03-12 21:17  haihai187  阅读(126)  评论(0编辑  收藏  举报