Advertisement
Aborigenius

AverageCharDelimeter

Jul 2nd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 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 AverageCharDelimeter
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             string noSpaces = input.Replace(" ", "");
  15.             // string[] inputArray = Console.ReadLine().Split(' ').ToArray();
  16.             byte[] asciiArray = Encoding.ASCII.GetBytes(noSpaces).ToArray();
  17.             int sum = 0;
  18.             for (int i = 0; i < asciiArray.Length; i++)
  19.             {
  20.                 sum += asciiArray[i];
  21.             }
  22.             int asciiChar = sum / noSpaces.Length;
  23.             char delimeter = Convert.ToChar(asciiChar);
  24.             char delimeterUpper = char.ToUpper(delimeter);
  25.  
  26.             string result = input.Replace(' ', delimeterUpper);
  27.             Console.WriteLine(result);
  28.         }
  29.  
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement