package com.codegym.task.task05.task0531;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Improving functionality
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
int d = Integer.parseInt(reader.readLine());
int e = Integer.parseInt(reader.readLine());
System.out.println("Minimum = " + min(a,b,c,d,e));
}
public static int min(int a, int b, int c, int d, int e)
{
int minimum = Math.min(a,b);
int mimi = Math.min(minimum,c);
int mim = Math.min(mimi, d);
int mi = Math.min(mim, e);
return mi;
}
}
How can I improve my code? I need help understanding how to efficiently do min/max with swaps
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Ewerton Backend Developer
11 July 2019, 13:46
You could use something like:
0
karina abad Software Developer at Intuit
12 July 2019, 20:52
Thank you!
0