#include<stdio.h>
void main()
{
int a[]={0,1,1,1,1,1,0,0,0,0,0,1},i=0;
static int o=0,e=0;//e for no. of 1's in array and o means no. of 0 in array
int l=sizeof(a)/4;
while(i<l)
{
if(a[i]==0)
{ o++;i++;}
else
{e++,i++;}
}
if(e>o) //if n0. of 1's greater than no. of 0's then e=o
e=o;
for(i=0;i<(e*2);i++)
{
a[i]=i%2;
}
for(i=e*2;i<l;i++)
{
if(o>e)
a[i]=0;
else if(e>o)
a[i]=1;
}
for(i=0;i<l;i++)
{
printf("%d",a[i]);
}
}
i think that this code will work.if any problem in this code u can ask
freely on [email protected].
--
~Pathak~
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.