kisame1313

Untitled

Jul 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication
  4. {
  5.     class Program
  6.     {
  7.         //абвгдеёжзийклмнопрстуфхцчшщъыьэюя
  8.         static void Main ( string [] args )
  9.         {
  10.             Console.WriteLine ( Clamp ( 'я', 'я', 'а', 4 ) );
  11.         }
  12.  
  13.         static char Clamp ( char currentSymb, char maxSymb, char minSymb, int shift )
  14.         {
  15.             int newSymb = currentSymb + shift;
  16.             if ( newSymb < minSymb )
  17.             {
  18.                 return Convert.ToChar ( minSymb + ( minSymb - newSymb ) );
  19.             }
  20.             else if ( newSymb > maxSymb )
  21.             {
  22.                 return Convert.ToChar ( minSymb + ( newSymb % maxSymb - newSymb / maxSymb ) );
  23.             }
  24.             else
  25.             {
  26.                 return Convert.ToChar ( newSymb );
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment