Skip to content

Instantly share code, notes, and snippets.

@rajeevs1992
Created January 22, 2013 14:35
Show Gist options
  • Save rajeevs1992/4595074 to your computer and use it in GitHub Desktop.
Save rajeevs1992/4595074 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#define SIZE(n) (n+8-(n%8))/8
main()
{
int upper,temp,i;
printf("Enter the largest number in list ");
scanf("%d",&upper);
upper+=1;
unsigned char list[SIZE(upper)];
for(temp=0;temp<SIZE(upper);temp++)
list[temp]=0;
printf("\nEnter list ");
scanf("%d",&temp);
while(temp<upper)
{
list[temp/8]=list[temp/8]|(1<<temp%8);
scanf("%d",&temp);
}
for(temp=0;temp<SIZE(upper);temp++)
for(i=0;i<8;i++)
if((list[temp]&(1<<i))!=0)
printf("%d\t",temp*8+i);
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment