중위수 구하기

2010. 3. 25. 11:022010년/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;
}

}

'2010년 > 30계단1~2단계' 카테고리의 다른 글

사주 팔자 구하기~  (0) 2010.03.25
삼각형 성립조건  (0) 2010.03.25
윤년 구하기  (0) 2010.03.25
수영장 가는 날~  (0) 2010.03.25
분수 크기 비교  (0) 2010.03.25