f i give input like 1,1,4,5,6,1,2,5,4,1,2, then output
should be like : 1-4, 2-2, 4-2, 5-1, 6-1 which means 1
occurs 4 times, 2 occurs 2 times like so.
Answer Posted / nag
int[] dup = {1,1,4,5,6,1,2,5,4,1,2};
int[] kk = new int[10];
foreach(int k in dup)
{
kk[k] = kk[k] + 1;
}
for (int i = 0; i < 10; i++)
{
if (kk[i] != 0)
Console.Write(i.ToString() + " - " + kk
[i].ToString() + ", ");
}
Console.ReadLine();
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Is c# dictionary a hash table?
What is readline c#?
What is exe file in c#?
How does it work?
Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?
Why do we need a singleton class?
How long has c# been around?
What is a scope in c#?
What's the difference between the debug class and trace class? Documentation looks the same.
what is difference between destruct or and garbage collection ?
Explanation on Generic?
Why do we use Design Pattern in C#?
Is as keyword in c#?
How many kinds of elements an array can have?
Is c# code is managed or unmanaged code?