tissiana

CharactersInRange

Oct 24th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 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 CaractersInRange
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             char start = char.Parse(Console.ReadLine());
  14.             char end = char.Parse(Console.ReadLine());
  15.             PrintsCharactersInRange(start, end);
  16.         }
  17.         public static void PrintsCharactersInRange(char start, char end)
  18.         {
  19.             string charactersInBetween = string.Empty;
  20.             if((char)end > (char)start)
  21.             {
  22.                 for (int i = start + 1; i < end; i++)
  23.                 {
  24.                     charactersInBetween += (char)i + " ";
  25.                 }
  26.  
  27.             }
  28.             if ((char)end < (char)start)
  29.             {
  30.                 for (int i = end + 1; i < start; i++)
  31.                 {
  32.                     charactersInBetween += (char)i + " ";
  33.                 }
  34.             }
  35.  
  36.             Console.WriteLine(charactersInBetween);
  37.  
  38.            
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment