Guest User

Untitled

a guest
Nov 23rd, 2018
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. namespace _01.EncryptSortandPrintArray
  2. {
  3.     using System;
  4.     using System.Linq;
  5.  
  6.     public class Program
  7.     {
  8.         public static void Main()
  9.         {
  10.             int numberStrings = int.Parse(Console.ReadLine());
  11.  
  12.             int[] numbers = new int[numberStrings];
  13.  
  14.             string vowels = "aAeEiIoOuU";
  15.             char[] vowelsArr = vowels.ToCharArray();
  16.             string consonants = "bBcCdDfFgGhHjJkKlLmMnNpPqQrRsStTvVwWxXyYzZ";
  17.             char[] consonantsArr = consonants.ToCharArray();
  18.  
  19.             for (int i = 0; i < numberStrings; i++)
  20.             {
  21.                 string word = Console.ReadLine();
  22.                 char[] letters = word.ToCharArray();
  23.  
  24.                 int sum = 0;
  25.                 for (int j = 0; j < letters.Length; j++)
  26.                 {
  27.                     char currentChar = letters[j];
  28.                     if(vowelsArr.Contains(currentChar))
  29.                     {
  30.                         sum += letters[j] * letters.Length;
  31.                     }
  32.                     else if(consonantsArr.Contains(currentChar))
  33.                     {
  34.                         sum += letters[j] / letters.Length;
  35.                     }
  36.                 }
  37.                 numbers[i] = sum;
  38.             }
  39.  
  40.             Array.Sort(numbers);
  41.  
  42.             foreach (var element in numbers)
  43.             {
  44.                 Console.WriteLine($"{element}");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment