【2018.2.25】c++预习练习

学了一学期c语言之后预习c++,一些最基础的东西做起来还是得心应手的,先练练手感🙈C++ primer plus 和教材同步学习,大概会比上学期抓瞎学习要好得多吧。

 1 #include<iostream>
 2 int main()
 3 {
 4     using namespace std;
 5     cout << "Enter the distance measured by furlong";
 6     int fur;
 7     cin >> fur;
 8     cout << "convert the furlong to yard\n" << 220*fur;    //数值函数直接表示 
 9     return 0;
10 }
 1 #include<iostream>
 2 using namespace std;    //名称空间于函数之前
 3 double convert(double x);
 4 int main()
 5 {
 6     cout << "Please enter a Celsius value:";
 7     double cel;
 8     cin >> cel;
 9     cout << cel <<" degrees Celsius is " <<convert(cel)<<" degrees Fahrenheit.";
10     return 0;
11 }
12 double convert(double x)
13 {
14     double y;
15     y=1.8*x+32.0;
16     return y;
17 }

 

posted @ 2018-02-25 19:48  兔至  阅读(119)  评论(0编辑  收藏  举报