Aliendreamer

averagechardemiliter

Jun 29th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 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 _02ArrayAndListAlgorithumsAverageCharDemiliters
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             List<string> inputTokens = Console.ReadLine().Split().ToList();
  15.             double tokensSum = 0;
  16.             int chartotal = 0;
  17.  
  18.             for (int i=0;i<inputTokens.Count;i++)
  19.             {
  20.                 char[] temp = inputTokens[i].ToCharArray();
  21.                 for (int j=0;j< temp.Length;j++)
  22.                 {
  23.                     tokensSum += (int)temp[j];
  24.                     chartotal++;
  25.                 }
  26.  
  27.             }
  28.             char demiliter = (char)(Math.Floor(tokensSum /chartotal));
  29.             if ((char)97 <= demiliter || demiliter <= (char)122)
  30.             {
  31.                 Console.WriteLine(string.Join($"{demiliter.ToString().ToUpper()}", inputTokens));
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine(string.Join($"{demiliter}", inputTokens));
  36.             }
  37.  
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment