指针函数

来源:互联网 发布:二手货车估价软件 编辑:程序博客网 时间:2024/05/20 05:25
#include <stdio.h>


int main()
{
    int func(int *p1, int *p2, int *p3);
    int a, b, c;
    
    int *pointer_1 = &a;
    int *pointer_2 = &b;
    int *pointer_3 = &c;
    
    printf ("enter a b c:");
    scanf ("%d %d %d", &a, &b, &c);
    
    func(pointer_1, pointer_2, pointer_3);
    printf("%d %d %d",*pointer_1, *pointer_2, *pointer_3);
    return 0;
}


int func(int *p1, int *p2, int *p3)
{
    int func1 (int *z1, int *z2);


    if (*p1 < *p2)
    {
        func1(p1, p2);
    }
    if (*p1 < *p3)
    {
        func1(p1, p3);
    }
    if (*p2 < *p3)
    {
        func1(p2, p3);
    
    }
    return 0;
}
int func1(int *z1, int *z2)
{
    int temp;
    temp = *z1;
    *z1 = *z2;
    *z2 = temp;
    return 0;
}
0 0