多种类型的指针
2015-10-05 17:30
169 查看
函数指针:
多种类型的指针总结:
比如用函数指针变量做参数,求最大值,最小值,和两数之和
多种类型的指针总结:
比如用函数指针变量做参数,求最大值,最小值,和两数之和
#include <stdio.h> #include <iostream> using namespace std; int main() { int a, b, max(int , int), min(int , int), add(int , int ); void process(int, int, int (*fun)(int , int)); scanf("%d%d", &a, &b); process(a, b, max); process(a, b, min); process(a, b, add); return 0; } void process(int x, int y, int (*fun)(int , int)) { int result; result = (*fun)(x, y); printf("%d\n", result); } int max(int x, int y) { return x > y ? x : y; } int min(int x, int y) { return x > y ? y : x; } int add(int x, int y) { return x+y; }
相关文章推荐
- JFinal开发8个常见问题
- Git使用
- android 处理空listview
- 数据结构【线性表(二)链表】项目之猴子选大王
- 第三周 项目1 顺序表的基本运算
- 惨不忍睹的简单计算器窗口
- 第六周--项目二--建立链栈算法库
- 20151005考试总结
- pudn下载地址的规律
- 一个noconsole程序
- 【项目4 - 建设双链表算法库】
- 第六周上机实践项目2——建立链栈算法库
- 第6周、项目1—建立顺序栈算法库
- [AndroidUI]使用DrawerLayout实现侧滑菜单
- 企业所得税
- HDU 5495 LCS
- 企业所得税
- 从Azure虚拟机下载文件到本地五种方法
- 第二周-项目1 - C/C++语言中函数参数传递的三种方式
- VS2010中CString和char*数据的转换