Advertisement
milislavski

TextToNumber-Redacted

Mar 29th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. class Printing
  4. {
  5.     static void Main()
  6.     {
  7.         int M = int.Parse(Console.ReadLine());
  8.  
  9.         String str = Console.ReadLine();
  10.  
  11.         long result = 0;
  12.  
  13.         foreach (var ch in str)
  14.         {
  15.             if (ch == '@')
  16.             {
  17.                 break;
  18.             }
  19.             else if (ch >= 'a' && ch <= 'z')
  20.             {
  21.                 result = result + (ch - 'a');
  22.             }
  23.             else if (ch >= 'A' && ch <= 'Z')
  24.             {
  25.                 result = result + (ch - 'A');
  26.             }
  27.             else if (ch >= '0' && ch <= '9')
  28.             {
  29.                 result = result * (ch - '0');
  30.             }
  31.            
  32.             else
  33.             {
  34.                 result = result % M;
  35.             }
  36.         }
  37.         Console.WriteLine(result);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement