Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication
- {
- class Program
- {
- //абвгдеёжзийклмнопрстуфхцчшщъыьэюя
- static void Main ( string [] args )
- {
- Console.WriteLine ( Clamp ( 'я', 'я', 'а', 4 ) );
- }
- static char Clamp ( char currentSymb, char maxSymb, char minSymb, int shift )
- {
- int newSymb = currentSymb + shift;
- if ( newSymb < minSymb )
- {
- return Convert.ToChar ( minSymb + ( minSymb - newSymb ) );
- }
- else if ( newSymb > maxSymb )
- {
- return Convert.ToChar ( minSymb + ( newSymb % maxSymb - newSymb / maxSymb ) );
- }
- else
- {
- return Convert.ToChar ( newSymb );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment