Advertisement
Guest User

Untitled

a guest
Jul 17th, 2021
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         string data = "";
  9.         int[] result = new int[n];
  10.         char[] vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
  11.         char[] consonants = {'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Z', 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z', 'y', 'Y'};
  12.         //Console.WriteLine(consonants[1]);
  13.         int res = 0;
  14.         for (int i = 1; i <= n; i++)
  15.         {
  16.             data = Console.ReadLine();
  17.             for (int j = 0; j < data.Length; j++)
  18.             {
  19.                 //if(data[j] >= 65 && data[j] <= 90 || data[j] >= 97 && data[j] <= 122){
  20.                 var isVowel = false;
  21.                 for (int k = 0; k < vowels.Length; k++)
  22.                 {
  23.                     if (data[j] == vowels[k])
  24.                     {
  25.                         res += (int)vowels[k] * data.Length;
  26.                         isVowel = true;
  27.                     }
  28.                 }
  29.                 if (isVowel) continue; //ако е- към следващия char
  30.                 res += (int)data[j] / data.Length;
  31.             //}
  32.             }
  33.  
  34.             result[i - 1] = res;
  35.             res = 0;
  36.         }
  37.  
  38.        
  39.         for (int elem = 0; elem < result.Length - 1; elem++)
  40.         {
  41.             for (int swp = elem + 1; swp < result.Length; swp++)
  42.             {
  43.                 int temp = 0;
  44.                 if (result[elem] > result[swp])
  45.                 {
  46.                     temp = result[elem];
  47.                     result[elem] = result[swp];
  48.                     result[swp] = temp;
  49.                 }
  50.             }
  51.         }
  52.  
  53.         foreach (var item in result)
  54.         {
  55.             Console.WriteLine(item);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement