fbinnzhivko

02. Numerology

Mar 17th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         string[] input = Console.ReadLine().Split('.', ' ');
  7.  
  8.         int day = Convert.ToInt32(input[0]);
  9.         int mounth = Convert.ToInt32(input[1]);
  10.         int year = Convert.ToInt32(input[2]);
  11.         string username = input[3];
  12.  
  13.         double total = day * mounth * year;
  14.         //Console.WriteLine("{0}*{1}*{2}={3}", day, mounth, year, total);
  15.  
  16.         if (mounth % 2 == 1) { total = total * total; }
  17.  
  18.         Console.WriteLine(total);
  19.  
  20.         for (int i = 0; i < username.Length; i++)
  21.         {
  22.             char currentChar = username[i];
  23.  
  24.             if (currentChar >= '0' && currentChar <= '9'){total += currentChar - '0';}
  25.             else if (currentChar >= 'a' && currentChar <= 'z'){total += currentChar - 'a' + 1;}
  26.             else if (currentChar >= 'A' && currentChar <= 'Z'){total += 2 * (currentChar - 'A' + 1);
  27.             }
  28.         }
  29.         while (total > 13)
  30.         {
  31.             int digitSum = 0;
  32.  
  33.             while (total > 0)
  34.             {
  35.                 digitSum += (int)(total % 10);
  36.                 total /= 10;
  37.             }
  38.  
  39.             total = digitSum;
  40.         }
  41.  
  42.         Console.WriteLine(total);
  43.     }
  44. }
Add Comment
Please, Sign In to add comment