TheBulgarianWolf

Ascii Sumator

Mar 22nd, 2021
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace AsciiSumator
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             char firstChar = Console.ReadLine()[0];
  10.             char secondChar = Console.ReadLine()[0];
  11.             int sum = 0;
  12.             string line = Console.ReadLine();
  13.             foreach(char ch in line)
  14.             {
  15.                 if(ch >= firstChar && ch <= secondChar)
  16.                 {
  17.                     sum += (int)ch;
  18.                 }
  19.             }
  20.             Console.WriteLine(sum);
  21.         }
  22.     }
  23. }
  24.  
Add Comment
Please, Sign In to add comment