您的位置:首页 > 编程语言 > C语言/C++

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: