UVA 11727 – Cost Cutting

Easiest way is to sort and print the middle number.

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * 
 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
 * 
 */
public class P11727 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    int T = sc.nextInt();
    for (int i = 1; i <= T; i++) {
      int[] list = { sc.nextInt(), sc.nextInt(), sc.nextInt() };
      Arrays.sort(list);
      out.println("Case " + i + ": " + list[1]);
    }
    out.close();
    sc.close();
  }

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.