Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created April 6, 2017 04:12
Show Gist options
  • Save Abdujabbar/c21e5ae8be421959763288d9453c2e66 to your computer and use it in GitHub Desktop.
Save Abdujabbar/c21e5ae8be421959763288d9453c2e66 to your computer and use it in GitHub Desktop.
MiniMaxSum
public class MiniMaxSum {
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
long _max = 0, _min = 1000000000;
long sum = 0;
long n;
for(int i = 0; i < 5; i++) {
n = in.nextLong();
sum = sum + n;
if (_min > n) {
_min = n;
}
if (_max < n) {
_max = n;
}
}
out.println((sum - _max) + " " + (sum - _min));
out.flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment