the problem in the code is this it counts the number again and again...i know what is the mistake but i dont know how to resolve it...please help...thanks
#include<iostream>
//#include<conio.h>
//#include<math.h>
int main()
{
int x[10]={1,2,3,2,1,3,4,5,4,3};
for(int i=0;i<10;i++)
{
int count=0;
for(int j=0;j<10;j++)
{
if(x[j]==x[i])
{
count=count+1;
}
}
std::cout<<x[i]<<" comes "<<count<<" times \n ";
}
std::cin.get();
}
/*
1 comes 2 times
2 comes 2 times
3 comes 3 times
2 comes 2 times
1 comes 2 times
3 comes 3 times
4 comes 2 times
5 comes 1 times
4 comes 2 times
3 comes 3 times
*/
If you want to avoid the duplicate results make your i loop start at 1 and end at 5....I think
it diddnt work.....and if it works, i wont be chaning this as changing range of i mean if i change the array, the numbers, then i need to change i accordingly....