Advertisement
silvana1303

print part of ascii table

May 25th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace exampreparation
  7. {
  8.     class exam
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int number1 = int.Parse(Console.ReadLine());
  13.             int number2 = int.Parse(Console.ReadLine());
  14.  
  15.             int duration = (number2 - number1) + 1; // пишем плюс едно,защото ще имаме нужда от 6 индекса
  16.  
  17.             char[] charArray = new char[duration];
  18.  
  19.             for (int i = 0; i < duration; i++) // без =,защото индексите са от 0 до 5 включително
  20.             {
  21.                 charArray[i] = (char)(i + number1); // кастваме чар за да се принтира символ
  22.                
  23.             }
  24.  
  25.             Console.WriteLine(string.Join(" ",charArray));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement