Advertisement
BSO90

Game

Jun 11th, 2021
1,072
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.  
  3. namespace Mock_exam_2_Task_1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number = int.Parse(Console.ReadLine());
  10.             int sum = 0;
  11.             int multiplication = 1;
  12.             bool isContainsOne = false;
  13.             while (number != 0)
  14.             {
  15.                 isContainsOne = false;
  16.                 int currDigit = number % 10;
  17.                 sum += currDigit;
  18.                 multiplication *= currDigit;
  19.  
  20.                 if (currDigit == 1)
  21.                 {
  22.                     isContainsOne = true;
  23.                 }
  24.  
  25.                 number /= 10;
  26.             }
  27.  
  28.             if (isContainsOne)
  29.             {
  30.                 multiplication += 1;
  31.             }
  32.  
  33.             if (multiplication > sum)
  34.             {
  35.                 Console.WriteLine(multiplication);
  36.             }
  37.  
  38.             else
  39.             {
  40.                 Console.WriteLine(sum);
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement