Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FrequentNumber
- {
- static void Main()
- {
- int[] equalNum = { 4, 1, 1, 4, 2, 3, 4, 4, 1, 2, 4, 9, 3 };
- int[] counter=new int[equalNum.Length];
- int secondCounter = 0;
- int frequentNum = 0;
- for (int index = 0; index < equalNum.Length-1; index++)
- {
- counter[index] = 1;
- for (int check = 1; check < equalNum.Length; check++)
- {
- if(equalNum[index] == equalNum[check])
- {
- counter[index] += 1;
- }
- if (counter[index] > secondCounter)
- {
- secondCounter = counter[index];
- frequentNum = equalNum[index];
- }
- }
- }
- Array.Sort(counter);
- Console.WriteLine(counter[counter.Length-1]+ " "+ frequentNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement