Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Unsorted array with most occurence
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here int [] x = {1,2,3,4,5,2,4,2,4,2,42,2,4,5,5,5}; int Majority = 0; int number, count; number = count = 0; for(int i = 0; i < x.Length; i++) { for(int j = i; j < x.Length; j++) { if(x[i] == x[j]) { count++; } } if(count > Majority) { Majority = count; number = x[i]; count = 0; } count = 0; } Console.WriteLine("No. "+ number + " comes "+ Majority); } } }
run
|
edit
|
history
|
help
0
character occurrence in the given string
Validate or get the check digit of a Windows activation installation ID / confirmation ID
Code challenge: Integer Comparison - Overkill - Composite Function
First code
*271*271#
test1
Work Days
constructortest
CommandForce3
งานสอบ