C++学习笔记
2017-01-13 08:55
274 查看
2016年12月27日
2.4.3 用户定义函数
2.4.3 用户定义函数
// ourfun.cpp -- define your own function #include<iostream> void simon(int); // function protype for simon() int main() { using namespace std; simon(4); // call the simon() funciton cout<< "Pick an interger:"; int count; cin>> count; simon(count); // call it again cout<< "Done!"<<endl; return 0; } void simon(int n){ using namespace std; cout<<"Simon says touch your toes" << n <<" times." << endl; } // void function don't need return stament
// convert.cpp --- converts stone to pounds #include<iostream> int stonetolb(int); // function prototype int main() { using namespace std; int stone; cout<<"Enter the weight in stone."; cin>>stone; int pounds = stonetolb(stone); cout<<stone<<"stone="; cout<<pounds<<"pounds."<<endl; return 0; } int stonetolb(int sts) { return 14*sts; }
相关文章推荐
- C语言中的 static变量、static函数
- 约瑟夫圆环的三种解决方案
- vc++中HBRUSH的几种用法
- const_cast的真正用途 (以前博客的内容)
- 前置++和后置++的一般被人忽略的一个重要区别
- C++文件读写详解(ofstream,ifstream,fstream)
- 程序员面试金典: 9.13 C和C++ 13.1 用C++方法,打印输入文件的最后K行。
- 简单的C++代码编写windows服务
- 计时函数的使用,以及chrono库的简单介绍
- C++之冒泡排序
- PAT乙级1033
- 值得推荐的C/C++框架和库
- c++ 深度优先算法走迷宫
- c++ 使用广度优先算法走迷宫并标记路径
- C语言_指针随笔
- C语言中常见的C的标准库函数
- C++中的继承
- C++时间
- C++特性的C语言实现(1)继承
- 用C语言打造自己的字符串拷贝函数