C语言排序
2014-12-17 19:25
204 查看
#import <Foundation/Foundation.h>//将函数指针的类型重定义;typedef int (*PFUN)(int, int);//1.最大值int maxValue(int x, int y);//2.最小值int min(int x, int y);//3.和int sumValue(int x, int y);//4.差int mul(int x, int y);//5.积int am(int x, int y);//6.商int dealer(int x, int y);//7.余数int yushu(int x, int y);//8.最大公约数;int scal(int x, int y);//9.最小公倍数int bei(int x, int y);void sayHello();int getValue();void assign(int *p, int count);typedef void (*PPP)();typedef int (*P1)();typedef void (*P2)(int *p, int count);//将一个数正序输出void positive (int n);//将一个数倒叙输出void revert(int n);//n的阶乘int fac(int n);typedef void (*rocky)(int n);//正序typedef void (*wesley)(int n);//倒序typedef int (*peter)(int n);//阶乘//求2个数的值//p 是函数指针,作用是接受函数的地址int number(int x, int y,PFUN p);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#import "Function.h"//1.最大值int maxValue(int x, int y) { return x > y ? x : y;}
//2.最小值int min(int x, int y) {
return x < y ? x : y;}//3.和int sumValue(int x, int y) { return x + y;
}//4.差int mul(int x, int y) { return x - y;
}//5.积int am(int x, int y) { return x * y;}//6.商int dealer(int x, int y){ return x / y;}//7.余数int yushu(int x, int y){ return x % y;
}//8.最大公约数;int scal(int x, int y) { int c = x % y; while (x % y != 0) { x = y; y = c; c = x % y;
} return y;}//9.最小公倍数int bei(int x, int y) { return x * y / scal(x, y);
}void sayHello() { printf("hello");
}int getValue() { return 20;
}void assign(int *p, int count) {
for (int i = 0; i < count; i++) { *(p + i) = arc4random() % (40 - 20 + 1) + 20; }}//正序输出void positive (int n) { if (n == 0) { return;//结束 } //1, 留一个数 int number = n % 10;//留取个位数 positive(n / 10);//找人 printf("%d", number);
}//倒序输出void revert(int n) { if (n == 0) { return; } int number = n % 10; printf("%d", number); revert(n / 10);
}//n的阶乘int fac(int n) { if (n == 0 || n == 1) { return 1; } return n * fac(n - 1);
}//求2个数的值int number(int x, int y, PFUN p) { //p = maxvalue; return p(x, y);
}
#import "Function.h"//1.最大值int maxValue(int x, int y) { return x > y ? x : y;}
//2.最小值int min(int x, int y) {
return x < y ? x : y;}//3.和int sumValue(int x, int y) { return x + y;
}//4.差int mul(int x, int y) { return x - y;
}//5.积int am(int x, int y) { return x * y;}//6.商int dealer(int x, int y){ return x / y;}//7.余数int yushu(int x, int y){ return x % y;
}//8.最大公约数;int scal(int x, int y) { int c = x % y; while (x % y != 0) { x = y; y = c; c = x % y;
} return y;}//9.最小公倍数int bei(int x, int y) { return x * y / scal(x, y);
}void sayHello() { printf("hello");
}int getValue() { return 20;
}void assign(int *p, int count) {
for (int i = 0; i < count; i++) { *(p + i) = arc4random() % (40 - 20 + 1) + 20; }}//正序输出void positive (int n) { if (n == 0) { return;//结束 } //1, 留一个数 int number = n % 10;//留取个位数 positive(n / 10);//找人 printf("%d", number);
}//倒序输出void revert(int n) { if (n == 0) { return; } int number = n % 10; printf("%d", number); revert(n / 10);
}//n的阶乘int fac(int n) { if (n == 0 || n == 1) { return 1; } return n * fac(n - 1);
}//求2个数的值int number(int x, int y, PFUN p) { //p = maxvalue; return p(x, y);
}
相关文章推荐
- c语言一些简单排序总结
- c语言排序方法
- C语言中的排序、二分查找
- 冒泡排序,插入排序,选择排序和快速排序-C语言
- 常见的C语言排序总结
- [算法练习]选择排序的C语言实现
- C语言中排序函数的用法
- C语言的排序、查找
- C语言 简单链表创建 排序 输出
- [C语言]基数排序
- 【学习ios之路:C语言】一维数组,数组排序,字符数组
- 【C语言】快速排序优质算法的动态显示和字符串的快排
- 插入排序的C语言实现
- 关于用C语言来实现对一个文档中的条目数字进行统计排序的实现
- C语言实验——各位数字之和排序 (sdut oj)
- C语言 选择排序
- C语言标准库函数qsort排序的介绍与使用
- C语言C++编程学习:排序原理分析
- c语言数组--选择排序