Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- namespace ConsoleTesting3
- {
- class ConsoleTesting3
- {
- private static void Main()
- {
- int[] test = new int[10];
- for (int i = 0; i < 10; i++)
- {
- Console.Write("Index {0}: ", i);
- test[i] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine();
- NumberOfOccurences(test);
- Console.ReadKey();
- }
- static void NumberOfOccurences(params int[] array)
- {
- var distincts = array.Distinct().ToArray();
- int count = 0;
- for (int i = 0; i < distincts.Length; i++)
- {
- for (int j = 0; j < array.Length; j++)
- {
- if (array[j] == distincts[i])
- {
- count++;
- }
- }
- Console.WriteLine("Number \"{0}\" found {1} times.", distincts[i], count);
- count = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment