Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace YaYunior4
- {
- class Program
- {
- static void Main(string[] args)
- {
- char symbol = Convert.ToChar(Console.ReadLine());
- Console.WriteLine((int)symbol);
- Console.WriteLine(Translate(symbol, 31));
- Console.WriteLine(Translate('а', 50) == 'т');
- Console.WriteLine(Translate('я', -3) == 'ь');
- Console.WriteLine(Translate('а', -3) == 'э'); //
- Console.WriteLine(Translate('б', -3) == 'ю'); //
- Console.WriteLine(Translate('б', 32) == 'б');
- Console.WriteLine(Translate('б', -32) == 'б');
- Console.WriteLine(Translate('б', 33) == 'в');
- Console.WriteLine(Translate('б', -33) == 'а');
- Console.WriteLine(Translate('б', 34) == 'г');
- Console.WriteLine(Translate('б', -34) == 'я'); //
- Console.WriteLine(Translate('б', 64) == 'б');
- Console.WriteLine(Translate('б', -64) == 'б');
- }
- static char Translate(char symbol, int translation, char min = 'а', char max = 'я')
- {
- int current = (int)symbol + (translation % 32);
- return symbol = Convert.ToChar(Clamp(current, (int)min, (int)max));
- }
- static int Clamp(int current, int min, int max)
- {
- int translate;
- if ((current > (int)max))
- {
- translate = (int)min + current - (int)max;
- }
- else
- {
- translate = current > (int)min ? current : (int)max - ((int)min - current) ;
- }
- return current = translate;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement