Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string allLangs = "Started from the bottom now we're here Started from the bottom now my whole team fucking here Started from the bottom now we're here".ToUpper();
- string[] langs = allLangs.Split(new char[] { ',', ';', ' ','.','!','\'','"','$','?','+' },
- StringSplitOptions.RemoveEmptyEntries);
- string kurr = string.Join("", langs);
- char[] letters = kurr.ToCharArray();
- Dictionary<char, int> dict = new Dictionary<char, int>();
- foreach (char t in letters)
- {
- if (!dict.ContainsKey(t))
- {
- dict.Add(t, 1);
- }
- else
- {
- dict[t]++;
- }
- }
- dict = dict.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
- Console.WriteLine("\nLetter occurence table:\n{0}\n",string.Join("\n",
- dict.Select(x => string.Format(@"'{0}' -> {1,2} {2}", x.Key, x.Value,new string('#',x.Value))).ToArray().Reverse()));
- /////////////////////////////////////// 2 reshenie //////////////////////////////////
- string allLangs = @"Started from the bottom now we're here
- Started from the bottom now my whole team fucking here
- Started from the bottom now we're here".ToUpper();
- string[] langs = allLangs.Split(new char[] { ',', ';', ' ', '.', '!', '\'', '"', '$', '?', '+' },
- StringSplitOptions.RemoveEmptyEntries);
- string kurr = string.Join("", langs);
- char[] letters = kurr.ToCharArray();
- Dictionary<char, int> dict = new Dictionary<char, int>();
- foreach (char t in letters)
- {
- if (!dict.ContainsKey(t))
- {
- dict.Add(t, 1);
- }
- else
- {
- dict[t]++;
- }
- }
- List<KeyValuePair<char, int>> myList = dict.ToList();
- myList.Sort(
- delegate(KeyValuePair<char, int> firstPair,
- KeyValuePair<char, int> nextPair)
- {
- return firstPair.Value.CompareTo(nextPair.Value);
- }
- );
- myList.Reverse();
- var k = 0;
- foreach (var dr in myList)
- {
- k++;
- if (k >= 11) break;
- Console.WriteLine("{0} = {1,3} -> {2,1}",dr.Key , dr.Value , new string('#', dr.Value));
- }
- ////////////////////// 3 reshenie vzimane samo na glavnite bukvi i razdelqne s REGEX addvane v LIST //////////////////////////////////////////
- string allLangs = @"Started From The Bottom Now We'Re Here
- Started From The Bottom Now My Whole Team Fucking Here
- Started From The Bottom Now We'Re Here";
- string regex = @"[A-Z]";
- MatchCollection separatorsInSentance = Regex.Matches(allLangs, regex);
- List<object> LList = new List<object>();
- foreach (var s in separatorsInSentance)
- {
- LList.Add(s);
- }
- string kurr = string.Join("", LList);
- char[] letters = kurr.ToCharArray();
- Dictionary<char, int> dict = new Dictionary<char, int>();
- foreach (char t in letters)
- {
- if (!dict.ContainsKey(t))
- {
- dict.Add(t, 1);
- }
- else
- {
- dict[t]++;
- }
- }
- List<KeyValuePair<char, int>> myList = dict.ToList();
- myList.Sort(
- delegate(KeyValuePair<char, int> firstPair,
- KeyValuePair<char, int> nextPair)
- {
- return firstPair.Value.CompareTo(nextPair.Value);
- }
- );
- myList.Reverse();
- var k = 0;
- foreach (var dr in myList)
- {
- k++;
- if (k >= 11) break;
- Console.WriteLine("{0} = {1,3} -> {2,1}",dr.Key , dr.Value , new string('#', dr.Value));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement