feiers

导航

【小学生入门级C++例题】第七章函数【第一天 学习C++】

【第一天】学习C++ 自己本身有些功底,现在就想要全新复习一下,就从最基本的写例题,思考,开始吧!

C++入门书上的实例,应该是最初级,想要解释函数原型的问题。

今天是开始记录自己的学习的开始,不做过多解析。

 1 #include "stdafx.h"
2 #include <iostream>
3
4 void cheers(int);
5 double cube (double x);
6
7 int _tmain(int argc, _TCHAR* argv[])
8 {
9 using namespace std;
10 cheers(5);
11 cout << "Give me a number: ";
12 double side;
13 cin >> side;
14 double volume = cube(side);
15 cout << "A " << side <<"-foot cube has a volume of ";
16 cout << volume << " cubic feet.\n";
17 getchar();
18 cheers(cube(2));
19 getchar();
20 return 0;
21 }
22
23 void cheers(int n)
24 {
25 using namespace std;
26 for (int i = 0;i < n;i++)
27 cout << "Cheers!";
28 cout << endl;
29 }
30
31 double cube(double x)
32 {
33 using namespace std;
34 return x * x * x;
35 }



posted on 2011-12-07 23:54  非韩非子  阅读(361)  评论(0编辑  收藏  举报