BIT MANIPULATION SE HOGA
using namespace std;
#include<iostream>
int get( int a , int pos)
{
return (( a & ( 1 << pos))!=0);
}
int set( int a , int pos)
{
return a | ( 1<<pos);
}
void ank ( int array[] , int a )
{
int res=0 ;
for( int i =0 ; i<4; i++)
{
int c=0; // I DID A MISTAKE THAT I INITILIZED THIS FROM THERE
BUT IT SHOULD BE ZERO AGAIN AND AGAIN ....
for( int j =0 ; j<a ;j++) // 1 ,1, 1, 4, 2 ,2 ,2 , 3 ,3 ,3
{
if(get( array[j] , i))
{
c++;
}
}
cout<<c<<" "<<endl;
if(c%3!=0)
{
res=set( res , i ) ;
}
}
cout<<res;
}
int main()
{
int array[]={ 1 ,1, 1, 9 ,3 ,3 ,3 };
ank( array , 7);
}
Comments
Post a Comment