Advertisement
BSO90

Game

Jun 11th, 2021
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Task_1
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int number = int.Parse(Console.ReadLine());
  11.             var numbers = new List<int>();
  12.             int sum = 0;
  13.             int product = 1;
  14.             int result = 0;
  15.             while (number != 0)
  16.             {
  17.                 int currDigit = number % 10;
  18.                 numbers.Add(currDigit);
  19.                 number /= 10;
  20.             }
  21.  
  22.             int firstDigit = numbers[0];
  23.             int secondDigit = numbers[1];
  24.             int thirdDigit = numbers[2];
  25.             sum = firstDigit + secondDigit + thirdDigit;
  26.             product = firstDigit * secondDigit * thirdDigit;
  27.             if (firstDigit == 1 || secondDigit == 1 || thirdDigit == 1)
  28.             {
  29.                 product += 1;
  30.             }
  31.  
  32.             result = Math.Max(product, sum);
  33.             Console.WriteLine(result);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement