12-函数指针,函数回调,动态内存排序
来源:互联网 发布:支持windows的手机 编辑:程序博客网 时间:2024/06/04 19:01
// 函数指针???
void fun1();
void fun1()
{
}
// 练习1
void printHello();
void printHello()
{
}
void practice1();
void practice1()
{
}
// 练习2
// 求和函数
int sum(int a, int b);
int sum(int a, int b)
{
}
// 求最大值
int maxValue(int a, int b);
int maxValue(int a, int b)
{
}
void practice2();
void practice2()
{
}
// 函数回调(函数指针作为参数)
// 返回值:int类型
// 函数名:getValue
// 参数列表:1.a(int类型)
int getValue(int a, int b, int (*p)(int, int));
int getValue(int a, int b, int (*p)(int, int))
{
}
// 练习3
// 写一函数查找成绩90分以上的学员,使用回调函数在姓名后加”高富帅”
typedef struct {
} Student;
// 打印所有学生的函数
void printStudents(Student *stus, int count);
void printStudents(Student *stus, int count)
{
}
// 修改学生姓名函数
void changeStudentName(Student *stu);
void changeStudentName(Student *stu)
{
}
// 函数两个参数:
// 1. 学生数组
// 2. 修改姓名的函数指针
void practice3(Student *stus, int count, void(*p)(Student *stu));
void practice3(Student *stus, int count, void(*p)(Student *stu))
{
}
// 动态排序
// 为函数指针起别名
typedef BOOL(*PFUN)(Student *stu1, Student *stu2);
// 按姓名排序
BOOL sortByName(Student *stu1, Student *stu2);
BOOL sortByName(Student *stu1, Student *stu2)
{
}
// 按年龄排序
BOOL sortByAge(Student *stu1, Student *stu2);
BOOL sortByAge(Student *stu1, Student *stu2)
{
}
// 按分数排序
BOOL sortByScore(Student *stu1, Student *stu2);
BOOL sortByScore(Student *stu1, Student *stu2)
{
}
// 动态排序,排序函数
void sortStudents(Student *stus,int count, PFUN p);
void sortStudents(Student *stus,int count, PFUN p)
{
}
// 函数返回值是函数指针
int min(int a, int b);
int min(int a, int b)
{
}
int max(int a, int b);
int max(int a, int b)
{
}
// 给函数指针起个别名
typedef int (*PFUN2) (int, int);
// 结构体指针与其对应的字符串
typedef struct {
} NameFunctionPair;
PFUN2 getFunctionByName(char *name);
PFUN2 getFunctionByName(char *name)
{
}
int main(int argc, const char * argv[])
{
}
- 12-函数指针,函数回调,动态内存排序
- 《IOS_C语言》函数指针、函数回调、动态排序、函数返回值是函数指针
- iOS开发学习第十二课——函数指针定义 、函数回调 、动态排序
- C语言-函数指针+动态内存分配
- 王学岗函数指针+动态内存分配
- 动态排序实例(函数回调)
- 函数指针动态绑定
- 关于用指针作为函数参数申请动态内存
- 关于用函数指针参数申请动态内存的问题
- C++函数动态申请指针的内存管理
- 返回指针的函数及动态申请内存
- 关于用函数指针参数申请动态内存的问题
- 函数指针和指针函数,函数指针与回调
- [指针四] 通过函数进行动态内存申请---二级指针、函数返回值
- 函数指针---排序
- 冒泡排序-函数指针
- 指针函数逆序排序
- c语言中的内存管理(重点:动态内存申请释放,野指针,指针函数)
- 《PC-Lint检测中的常见错误》 android - lint 常见错误
- jsp+ajax+json
- C/C++中的 static 变量和 static 函数
- POI学习笔记,Excel解析实现
- 坚持的意义
- 12-函数指针,函数回调,动态内存排序
- 15款值得学习的小型开源项目,带你快速步入开源世界
- html 验证码功能 不区分大小写进行验证。
- SQL server 2012 自动备份功能
- bootstrap3表格边框颜色
- git手动解决内容冲突
- 复选框单选框与文字对齐问题的研究与解决
- Quartz初学
- 10个你能参与并学习的Java开源项目