Program to print the numbers with Odd Occurences


#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[10],b[10];
int n,c;
cout<<"Enter the total numbers to be checked\n";
cin>>n;
cout<<"Enter the numbers\n";
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int j=0;j<n;j++)
{
int count=0;
if(a[j]==0)
{
c++;
continue;
}
for(int k=j+1;k<n;k++)
{
if(a[j]==a[k])
{
count++;
a[k]=0;
}
}
b[j-c]=count+1;
if(b[j-c]%2!=0)
cout<<"The numbers with odd occurence are\n"<<a[j]<<"\t";
}
getch();
}

Input : 8
3 3 3 4 4 6 7 7

Output :
3 6

Comments

Popular posts from this blog

Tricky Questions or Puzzles in C

Program to uncompress a string ie a2b3c4 to aabbbcccc

Number series arrangement puzzles