Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string sentence = Console.ReadLine();
- List<char> chars = new List<char>();
- List<int> counts = new List<int>();
- foreach (char c in sentence)
- {
- if (!chars.Contains(c))
- {
- chars.Add(c);
- counts.Add(1);
- }
- else
- {
- int index = chars.IndexOf(c);
- counts[index]++;
- }
- }
- for (int i = 0; i < chars.Count; i++)
- {
- Console.WriteLine($"[{chars[i]}] - {counts[i]}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement