1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
/*order.c file*/
#include <stdio.h>
void ascending2(int *ptr1, int *ptr2){
int temp;
if((*ptr1)>(*ptr2)){
temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
}
}
void ascending3(int *ptr1, int *ptr2, int *ptr3){
ascending2(ptr1, ptr2);
ascending2(ptr1, ptr3);
ascending2(ptr2, ptr3);
}
void descending3(int *ptr1, int *ptr2, int *ptr3){
ascending3(ptr3, ptr2, ptr1);
}
void order(int a, int b, int c, char d){
if(d == 'D'){
printf("ascending3 \n");
ascending3(&a, &b, &c);
}
if(d == 'A'){
printf("descending3 \n");
descending3(&a, &b, &c);
}
}
|