~cpp
#include <stdio.h>
int search_middleNum(int *, int *, int *);
void changeXY(int *, int *);
void main()
{
int a, b, c, middleNum;
while(1){
printf("멈추려면 '-999 0 0' 입력\n");
printf("비교할 A, B, C 값을 차례로 입력 : ");
scanf("%d %d %d", &a, &b, &c);
if(a == -999){
break;
}
middleNum = search_middleNum(&a, &b, &c);
printf("중위수 = %d", middleNum);
}
}
int search_middleNum(int *a, int *b, int *c)
{
int middle;
if(*a >= *b){changeXY(a, b);};
if(*a >= *c){changeXY(a, c);};
if(*b >= *c){changeXY(b, c);};
middle = *b;
return middle;
}
void changeXY(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}