Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class SymbolToNumber
- {
- static void Main()
- {
- int secretNumber = int.Parse(Console.ReadLine());
- string text = Console.ReadLine();
- byte[] asciiBytes = Encoding.ASCII.GetBytes(text);
- long result = 0;
- double finalResult = 0;
- for (int i = 0; i < text.Length; i++)
- {
- if (text[i] == '@')
- {
- break;
- }
- else if ((text[i] >= 'A' && text[i] <= 'Z') || (text[i] >= 'a' && text[i] <= 'z'))
- {
- result = (asciiBytes[i] * secretNumber) + 1000;
- }
- else if (text[i] >= '0' && text[i] <= '9')
- {
- result = asciiBytes[i] + secretNumber + 500;
- }
- else
- {
- result = asciiBytes[i] - secretNumber;
- }
- if (i % 2 == 0)
- {
- finalResult = (result / 100.0);
- Console.WriteLine("{0:F2}", finalResult);
- }
- else
- {
- finalResult = result * 100;
- Console.WriteLine(finalResult);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement