Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Game2 {
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- int N = scanner.nextInt();
- int[] intTab = String.valueOf(N).chars().map(Character::getNumericValue).toArray();
- int i = 0;
- int sumOfFirstTwo = intTab[0] + intTab[1] * intTab [2];
- int sumOfSecondTwo = intTab[0] * intTab[1] + intTab [2];
- int sumOfThidTwo = intTab[0] + intTab[1] + intTab [2];
- int sumOfFourthTwo = intTab[0] * intTab[1] * intTab [2];
- if(Math.max(sumOfFirstTwo,sumOfSecondTwo) > Math.max(sumOfThidTwo,sumOfFourthTwo)){
- System.out.print(Math.max(sumOfFirstTwo,sumOfSecondTwo));
- }
- else {
- System.out.print(Math.max(sumOfThidTwo,sumOfFourthTwo));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment