Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Int n =int.Parse(Console.ReadLine());
- intcounter =1;
- intmaxCounter =0;
- int[]arr =newint[n];
- intnum =0;
- for(inti =0;i <n;i++)
- {
- arr[i]=int.Parse(Console.ReadLine());
- }
- Array.Sort(arr);
- if(n ==1)
- {
- num =arr[0];
- }
- for(inti =0;i <n-1;i++)
- {
- if(arr[i]==arr[i+1])
- {
- counter++;
- }
- else
- {
- counter =0;
- }
- if(counter >maxCounter)
- {
- maxCounter =counter;
- num =arr[i];
- }
- }
- Console.WriteLine(num);
Advertisement
Add Comment
Please, Sign In to add comment