Advertisement
milislavski

Decoding

Apr 22nd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem2
  8. {
  9.     class Decoding
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int salt = int.Parse(Console.ReadLine());
  14.             double result = 0;
  15.             var encodedNumbers = new List<double>();
  16.             string text = Console.ReadLine();
  17.             for (int i = 0; i < text.Length; i++)
  18.             {
  19.                 if (text[i] == '@')
  20.                 {
  21.                     break;
  22.                 }
  23.                 else if (char.IsLetter(text[i]))
  24.                 {
  25.                     result = (int)text[i] * salt + 1000;
  26.                     if (i % 2 == 0)
  27.                     {
  28.                         result /= 100.0;
  29.                         Console.WriteLine("{0:F2}", result);
  30.                     }
  31.                     else
  32.                     {
  33.                         result *= 100;
  34.                         Console.WriteLine(result);
  35.                     }
  36.                 }
  37.                 else if (char.IsDigit(text[i]))
  38.                 {
  39.                     result = (int)text[i] + salt + 500;
  40.                     if (i % 2 == 0)
  41.                     {
  42.                         result /= 100.0;
  43.                         Console.WriteLine("{0:F2}", result);
  44.                     }
  45.                     else
  46.                     {
  47.                         result *= 100;
  48.                         Console.WriteLine(result);
  49.                     }
  50.                 }
  51.                 else
  52.                 {
  53.                     result = (int)text[i] - salt;
  54.                     if (i % 2 == 0)
  55.                     {
  56.                         result /= 100.0;
  57.                         Console.WriteLine("{0:F2}", result);
  58.                     }
  59.                     else
  60.                     {
  61.                         result *= 100;
  62.                         Console.WriteLine(result);
  63.                     }
  64.                 }
  65.                
  66.                
  67.             }
  68.            
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement