Advertisement
dragonbs

Encrypt, Sort, and Print Array

Feb 18th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. int.TryParse(Console.ReadLine(), out int lines);
  2.  
  3. int[] sequence = new int[lines];
  4.  
  5. for (int i = 0;i < lines; i++)
  6. {
  7.     string input = Console.ReadLine();
  8.  
  9.     int sum = 0;
  10.  
  11.     for (int j = 0; j < input.Length; j++)
  12.     {
  13.         if (input[j] == 'A' || input[j] == 'a' || input[j] == 'E' || input[j] == 'e'
  14.             || input[j] == 'I' || input[j] == 'i' || input[j] == 'O' || input[j] == 'o'
  15.             || input[j] == 'U' || input[j] == 'u')
  16.         {
  17.             sum += input[j] * input.Length;
  18.         }
  19.         else
  20.         {
  21.             sum += input[j] / input.Length;
  22.         }
  23.     }
  24.     sequence[i] = sum;
  25. }
  26.  
  27. Array.Sort(sequence);
  28. for (int k = 0; k < sequence.Length; k++)
  29. {
  30.     Console.WriteLine(sequence[k]);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement