C6_函数
来源:互联网 发布:嗨翻c语言kindle 编辑:程序博客网 时间:2024/06/18 16:19
函数种类
1.无返回值,无参数(无返回值用void)
void buyVegetable(){ printf("100块都不给我,怎么买菜\n"); int a = 10; a += 20;}
2.有返回值,无参数
int buyVegetableTwo(){ printf("老板没给我钱,我还挣了100\n"); return 100; // return下的代码不会被运行}
3.无返回值,有参数
void addNum(int a, int b){ printf("%d\n",a + b);}
4.有返回值,有参数
int addSum(int a, int b){ return a + b;}
练习.1 - n的求和
int sumValue(int n){ int sum = 0; for (int i = 0; i < n + 1; i++) { sum += i; } return sum;}
练习.编写函数,返回三个数中间的数
int midNum(a, b, c){ int max = a > b ? a : b; max = max > c ? max : c; int min = a < b ? a : b; min = min < c ? min : c; int mid = a + b + c - max - min; return mid;}
是在主函数中存在的数,形参则是用来接受调用时传过去的内容的容器.
0 0
- C6_函数
- C6_函数
- C6_函数
- C6_函数
- C6_函数
- C6_函数多文件管理
- C6_函数多文件管理练习
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- LuaFileSystem学习心得
- 多态
- 浅谈之对面向对象的理解
- HTML5事件——contextmenu 隐藏鼠标右键菜单
- OS中NSSearchPathForDirectoriesInDomains函数参数 NSDocumentDirectory, NSDocumentationDirectory, NSDownload
- C6_函数
- 【区间筛法】 LightOJ 1197 Help Hanzo
- 黑马程序员
- VS中MFC连接MySQL的方法
- TC剩余贷款分配规则
- ArrayAdapter
- 南阳oj 题目199 无线网络覆盖
- Algorithms—62.Unique Paths
- 黑马程序员 String StringBuffer