Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - using System;
 - using System.Collections.Generic;
 - namespace Task_1
 - {
 - class Program
 - {
 - static void Main(string[] args)
 - {
 - int number = int.Parse(Console.ReadLine());
 - var numbers = new List<int>();
 - int sum = 0;
 - int product = 1;
 - int result = 0;
 - while (number != 0)
 - {
 - int currDigit = number % 10;
 - numbers.Add(currDigit);
 - number /= 10;
 - }
 - int firstDigit = numbers[0];
 - int secondDigit = numbers[1];
 - int thirdDigit = numbers[2];
 - sum = firstDigit + secondDigit + thirdDigit;
 - product = firstDigit * secondDigit * thirdDigit;
 - if (firstDigit == 1 || secondDigit == 1 || thirdDigit == 1)
 - {
 - product += 1;
 - }
 - result = Math.Max(product, sum);
 - Console.WriteLine(result);
 - }
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment