매니저/JAVA1

JAVA1 else 예제2

cdprkr2077 2011. 12. 8. 19:33

 

 

// 정수 세개를 입력받아 else if로 비교후 가장 큰 수 하나만 출력

class ElseIfEx2
{
 public static void main(String[] args)
 {
  int a = Integer.parseInt( args[0] );
  int b = Integer.parseInt( args[1] );
  int c = Integer.parseInt( args[2] );
  
  if ( a > b && a > c ) System.out.println( "큰 수 : " + a );
  else if ( b > c ) System.out.println( "큰 수 : " + b );
  else System.out.println( "큰 수 : " + c );
 }
}

알고보면 매우 간단하고 쉬운...