Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FrequentNumbers
- {
- static void Main()
- {
- int[] array1 = new int[13] { 4, 1, 1, 4, 2, 3, 4, 4, 1, 2, 4, 9, 3 };
- for (int i = 0; i < array1.Length-1; i++)
- {
- for (int j = i+1; j < array1.Length; j++)
- {
- if (array1[i]>=array1[j])
- {
- int a = array1[i];
- array1[i] = array1[j];
- array1[j] = a;
- }
- }
- }
- int counter = 0;
- int bigCounter = 0;
- int whatNum = 0;
- for (int i = 0; i < array1.Length-1; i++)
- {
- if (array1[i] == array1[i + 1])
- {
- counter++;
- if (bigCounter <= counter)
- {
- bigCounter = counter;
- whatNum = array1[i];
- }
- }
- else
- {
- counter = 0;
- }
- }
- Console.WriteLine("We have {0} members of the number \"{1}\" in the array",bigCounter+1, whatNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement