@saurabh see if you print all the unique substrings and if the test cases
have unique digits then question makes no sense.

My question is :

if input is aaa
o/p must be a,aa,aaa .


On Sat, Oct 30, 2010 at 2:12 PM, Saurabh Koar <saurabhkoar...@gmail.com>wrote:

> This code works when u give integer input and all the digits are
> unique.Hope this will help u to solve your problem.U will understand
> the concept when u will go through the code.Modification is required..
>
>
> #include<stdio.h>
> //#include<conio.h>
> #include<malloc.h>
> #include<string.h>
> char *q[50];
> int count=0;  //counts the no of elements in the set
> int no_of_subsets;  //counts the no of subsets possible.Used to
> generate bit pattern from 0 to no_of_subsets-1
> int set[25]; //Elements are stored in this array
> void store_bits_in_char_array(int no)
> {
>     int len;
>     char temp[30];
>     int i,m=0;
>     //temp=(char *)malloc(sizeof(char )*count);
>     for(i=count-1;i>=0;i--)
>     {
>                           if((no&(1<<i))==0)
>                           temp[m]='0';
>                           else
>                           temp[m]='1';
>                           m++;
>     }
>     temp[m]='\0';
>     len=strlen(temp);
>     char *t;
>     t=(char *)malloc(sizeof(char )*(len+1));
>     strcpy(t,temp);
>     //printf("%s\n",temp);
>     q[no]=t;
>     //printf("%s\n",q[no]);
> }
> int count_no_of_subsets(int count)
> {
>    int i;
>    int ret_val=1;
>    for(i=1;i<=count;i++)
>    ret_val=ret_val*2;
>    return(ret_val);
> }
> void output(int n)
> {
>     printf("{");
>     int i;
>     for(i=0;i<count;i++)
>     {
>                         if(*(q[n]+i)=='1')
>                         printf("%d,",set[i]);
>                         else
>                         printf(" ");
>     }
>     printf("}");
> }
>
> int main()
> {
>    //int set[25];
>    int i=0;
>    int choice;
>    do
>    {
>        printf("Enter the element: ");
>        scanf("%d",&set[i]);
>        i++;
>        count++;
>        printf("Is there any more elements?(Press 1 for Yes/Press 0
> for No): ");
>        scanf("%d",&choice);
>    }while(choice==1);
>    //printf("%d\n",count);
>    no_of_subsets=count_no_of_subsets(count);
>    //printf("%d\n",no_of_subsets);
>    for(i=0;i<no_of_subsets;i++)
>    {
>          store_bits_in_char_array(i);
>    }
>    for(i=0;i<no_of_subsets;i++)
>    {
>      printf("\n");
>      output(i);
>      printf("\n");
>      }
>    getch();
>    return 0;
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Thanks & Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science & Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to