Advertisement
Sim0o0na

4. ASCII Combinations

Mar 12th, 2018
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 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 ForthExam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int digitSum = 0;
  15.             int smallLettersSum = 0;
  16.             int bigLetterSum = 0;
  17.             int otherSum = 0;
  18.             string digit = null;
  19.             string smallLetters = null;
  20.             string bigLetters = null;
  21.             string otherSymbols = null;
  22.             for (int i = 0; i < n; i++)
  23.             {
  24.                 char symbol = char.Parse(Console.ReadLine());
  25.  
  26.                 if (symbol >= '0' && symbol <= '9')
  27.                 {
  28.                     digitSum += (int)symbol;
  29.                     digit += symbol;
  30.                 }
  31.                 else if (symbol >= 'a' && symbol <= 'z')
  32.                 {
  33.                     smallLettersSum += (int)symbol;
  34.                     smallLetters += symbol;
  35.                 }
  36.                 else if (symbol >= 'A' && symbol <= 'Z')
  37.                 {
  38.                     bigLetterSum += (int)symbol;
  39.                     bigLetters += symbol;
  40.                 }
  41.                 else
  42.                 {
  43.                     otherSum += (int)symbol;
  44.                     otherSymbols += symbol;
  45.                 }
  46.  
  47.             }
  48.             if (digitSum >= smallLettersSum && digitSum >= bigLetterSum && digitSum >= otherSum)
  49.             {
  50.                 Console.WriteLine("Biggest ASCII sum is:{0}", digitSum);
  51.                 Console.WriteLine("Combination of characters is:{0}", digit);
  52.             }
  53.             else if (bigLetterSum >= smallLettersSum && bigLetterSum >= otherSum )
  54.             {
  55.                 Console.WriteLine("Biggest ASCII sum is:{0}", bigLetterSum);
  56.                 Console.WriteLine("Combination of characters is:{0}", bigLetters);
  57.             }
  58.             else if (smallLettersSum >= otherSum)
  59.             {
  60.                 Console.WriteLine("Biggest ASCII sum is:{0}", smallLettersSum);
  61.                 Console.WriteLine("Combination of characters is:{0}", smallLetters);
  62.             }
  63.             else
  64.             {
  65.                 Console.WriteLine("Biggest ASCII sum is:{0}", otherSum);
  66.                 Console.WriteLine("Combination of characters is:{0}", otherSymbols);
  67.             }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement