Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _01._Encrypt__Sort_and_Print_Array
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int num = int.Parse(Console.ReadLine());
  11.  
  12. string[] names = new string[num];
  13. int[] sums = new int[num];
  14.  
  15. int currentSum = 0;
  16. for (int i = 0; i < names.Length; i++)
  17. {
  18. names[i] = Console.ReadLine();
  19. string current = names[i];
  20. for (int j = 0; j < current.Length; j++)
  21. {
  22. char currentChar = current[j];
  23. int charToInt = currentChar;
  24.  
  25. if (currentChar == 'a' || currentChar == 'e' || currentChar == 'i' || currentChar == 'o' || currentChar == 'u'
  26. || currentChar == 'A' || currentChar == 'E' || currentChar == 'I' || currentChar == 'O' || currentChar == 'U')
  27. {
  28. currentSum += charToInt * current.Length;
  29. }
  30. else if ((currentChar >= 'a' && currentChar <= 'z') || (currentChar >= 'A' && currentChar <= 'Z'))
  31. {
  32. currentSum += charToInt / current.Length;
  33. }
  34. }
  35.  
  36. sums[i] = currentSum;
  37. currentSum = 0;
  38. }
  39.  
  40. int[] newSums = new int[num];
  41. int index = 0;
  42.  
  43. for (int i = 0; i < sums.Length; i++)
  44. {
  45. for (int j = 0; j < sums.Length; j++)
  46. {
  47.  
  48. if (sums[j] == sums.Min())
  49. {
  50. newSums[index] = sums[j];
  51. index++;
  52. sums[j] = int.MaxValue;
  53. break;
  54. }
  55. }
  56.  
  57. }
  58.  
  59. for (int i = 0; i < newSums.Length; i++)
  60. {
  61. Console.WriteLine(newSums[i]);
  62. }
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement