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
Give examples for reference types?
What are handlers in c#?
i want o/p 011242110 in c# code.
What is dll file in c#?
What is bit in c#?
What is returned if you pass the value 12.34 to the parsefloat () function?
What is delegates and events?
Structs are not reference types. Can structs have constructors?
How to Install uninstall assemblies into GAC?
Is a structure a class?
Explain how can you clean up objects holding resources from within the code?
Explain how can I get around scope problems in a try/catch?
Can c# inherit multiple classes?
What is a static in c#?
Is it possible to have a static indexer in c#?