Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace EncryptSortAndPrintArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int[] output = new int[num];
- for (int i = 0; i < num; i++)
- {
- char[] name = Console.ReadLine().ToCharArray();
- for (int j = 0; j < name.Length; j++)
- {
- switch (name[j])
- {
- case 'a':
- case 'e':
- case 'i':
- case 'o':
- case 'u':
- case 'A':
- case 'E':
- case 'I':
- case 'O':
- case 'U':
- output[i] += name[j] * name.Length;
- break;
- default:
- output[i] += name[j] / name.Length;
- break;
- }
- }
- }
- Array.Sort(output);
- foreach (var item in output)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
- Решение с тернарен оператор:
- using System;
- namespace EncryptSortAndPrintArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int[] output = new int[num];
- for (int i = 0; i < num; i++)
- {
- char[] name = Console.ReadLine().ToCharArray();
- for (int j = 0; j < name.Length; j++)
- {
- output[i] += "aeiouAEIOU".Contains(name[j]) ? name[j] * name.Length : name[j] / name.Length;
- }
- }
- Array.Sort(output);
- Console.WriteLine(string.Join("\n", output));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement