Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- //Read a list of integers in range [0…1000] and print them in ascending order along with their number of occurrences.
- namespace count_numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> nums = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> occurances = new List<int>();
- for (int i = 0; i < 1000; i++)
- {
- occurances.Add(0);
- }
- foreach (var num in nums)
- {
- occurances[num]++;
- }
- for (int num = 0; num < occurances.Count; num++)
- {
- if (occurances[num] > 0)
- {
- Console.WriteLine(num + " -> " + occurances[num]);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment