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



}