Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Test
- {
- class TestGround
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ').ToArray();
- Dictionary<string, int> myDict = new Dictionary<string, int>();
- for (int i = 0; i < input.Length; i++)
- {
- string current = input[i];
- int counter = 1;
- for (int j = i + 1; j < input.Length; j++)
- {
- if (current == input[j])
- {
- counter++;
- }
- }
- double percent = (counter / (double)input.Length) * 100;
- if (!myDict.ContainsKey(current))
- {
- Dictionary<int, double> inner = new Dictionary<int, double>();
- myDict.Add(current, counter);
- }
- }
- foreach (var str in myDict.OrderByDescending(x => x.Value))
- {
- double percent = (double)str.Value / input.Length * 100;
- Console.Write($"{str.Key} -> ");
- Console.WriteLine($"{str.Value} times ({percent:f2}%)");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement