중위수 구하기
2010. 3. 25. 11:02ㆍ2010년/30계단1~2단계
프로그램 명: med
제한시간: 1 초
세 정수를 입력으로 받아 이 수를 크기 순으로 나열할 때 중간에 위치한 수(중위수)를 구하는 문제이다.
입력
1000 이하의 자연수가 입력으로 주어진다. 세 수는 모두 같을 수 도 있다.출력
입출력 예
입력 1 5 2 출력 2 입력 2 2 2 출력 2 입력 2 5 2 출력 2
---------------
|
원래 사실 swap이랑 섞으면 되는데 -_-;;
#include<stdio.h>
int main()
{
int ione;
int itwo;
int ithree;
int iresult;
scanf("%d %d %d",&ione,&itwo,&ithree);
if(ione>itwo)
{
iresult=itwo;
}
else if(ione>ithree)
{
iresult=ithree;
}
else
{
iresult=ithree;
}
printf("%d\n",iresult);
return 0;
}
}