Advertisement
milislavski

Untitled

Apr 20th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4.  
  5. class ConsoleApplication1Exam15i16
  6. {
  7.     static void Main(string[] args)
  8.     {
  9.         string input = "";
  10.         int count = 0;
  11.         List<string> array = new List<string>();
  12.         while (true)
  13.         {
  14.             input = Console.ReadLine().ToUpper();
  15.  
  16.             if (input == "END")
  17.             {
  18.                 break;
  19.             }
  20.             if (count % 2 != 0)
  21.             {
  22.                 array.Add(input);
  23.             }
  24.             count++;
  25.         }
  26.         BigInteger sum = 1;
  27.         BigInteger sum2 = 1;
  28.         if (count < 10)
  29.         {
  30.             for (int i = 0; i <= array.Count - 1; i++)
  31.             {
  32.                 foreach (var symbol in array[i])
  33.                 {
  34.                     int number = symbol - '0';
  35.                     if (number != 0)
  36.                     {
  37.                         sum *= (BigInteger)number;
  38.                     }
  39.                     else
  40.                     {
  41.                         sum *= 1;
  42.                     }
  43.                 }
  44.             }
  45.             Console.WriteLine(sum);
  46.         }
  47.         else
  48.         {
  49.             for (int i = 0; i <= array.Count - 1; i++)
  50.             {
  51.                 if (i <= 4)
  52.                 {
  53.                     foreach (var symbol in array[i])
  54.                     {
  55.                         int number = symbol - '0';
  56.                         if (number != 0)
  57.                         {
  58.                             sum *= (BigInteger)number;
  59.                         }
  60.                         else
  61.                         {
  62.                             sum *= 1;
  63.                         }
  64.                     }
  65.                 }
  66.                 else
  67.                 {
  68.                     foreach (var symbol in array[i])
  69.                     {
  70.                         int number = symbol - '0';
  71.                         if (number != 0)
  72.                         {
  73.                             sum2 *= (BigInteger)number;
  74.                         }
  75.                         else
  76.                         {
  77.                             sum2 *= 1;
  78.                         }
  79.                     }
  80.                 }
  81.             }
  82.             Console.WriteLine(sum);
  83.             Console.WriteLine(sum2);
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement