TheBulgarianWolf

Encrypt, Sort and Print Array

Oct 17th, 2020
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5. using System.Numerics;
  6.  
  7. namespace SoftuniExercisesWithVariables
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             Console.WriteLine("Enter the number of lines you are about to enter: ");
  15.             int lines = int.Parse(Console.ReadLine());
  16.             List<int> numbersList = new List<int>();
  17.             string input = "";
  18.             while (lines > 0)
  19.             {
  20.                 int sum = 0;
  21.                 input = Console.ReadLine();
  22.                 int length = input.Length;
  23.                 foreach(char i in input)
  24.                 {
  25.                     switch (i)
  26.                     {
  27.                         case 'a':
  28.                         case 'e':
  29.                         case 'i':
  30.                         case 'o':
  31.                         case 'u':
  32.                             sum += ((int)i*length);
  33.                             break;
  34.                         default:
  35.                             sum += ((int)i/length);
  36.                             break;
  37.                     }
  38.                    
  39.  
  40.                 }
  41.                 numbersList.Add(sum);
  42.                 sum = 0;
  43.                 lines--;
  44.             }
  45.  
  46.             numbersList.Sort();
  47.             foreach(int k in numbersList)
  48.             {
  49.                 Console.WriteLine(k);
  50.             }
  51.  
  52.         }
  53.     }
  54. }
  55.  
Add Comment
Please, Sign In to add comment