Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Bai1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<char, int> res = new Dictionary<char, int>();
- string s = Console.ReadLine();
- foreach (char value in s)
- {
- if (value != ' ')
- {
- if (res.ContainsKey(value)) res[value]++;
- else res.Add(value, 1);
- }
- }
- int maxValue = 0;
- int dem = 1;
- char valueCurrent = ' ';
- foreach (KeyValuePair<char, int> item in res)
- {
- if (maxValue < item.Value)
- {
- dem = 1;
- maxValue = item.Value;
- valueCurrent = item.Key;
- }
- else if (maxValue == item.Value) dem++;
- }
- if (dem > 1)
- {
- foreach (KeyValuePair<char, int> item in res)
- {
- if (item.Value == maxValue && item.Key - '0' < valueCurrent - '0') valueCurrent = item.Key;
- }
- }
- Console.WriteLine($"{res.Count}\n{valueCurrent}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement