i think there is only one and srtaight forwad way to do this... i m writing C code for that.....if any one can do it with less complexity....plz reply..
int flag; do{ flag=0; for(int i =0;subject[i] !='\0';i++) { if(subjcet[i]==pattern[0]){ for(int j=i,k=1;pattern[k]!='\0'&&subject[j]==pattern[k];j++,k++); if(pattern[k]=='\0'){ while(subject[i+k]!='\0') subject[i]=subject[i+k]; break; flag=1; } } }while(flag==1); On 8/8/07, Arulanandan P <[EMAIL PROTECTED]> wrote: > > This was asked to me in Microsoft interview > > > On 8/7/07, Abhi <[EMAIL PROTECTED]> wrote: > > > > > > Is this your college assignment? > > > > > > On Aug 7, 9:00 pm, "Arulanandan P" <[EMAIL PROTECTED]> wrote: > > > You have to write a function whose prototype is given bellow. this > > function > > > will accept two char * named subject and pattern. for example > > > subject="abracadbra" > > > and pattern="bca".now it should check occurrences of all chars of > > string > > > pattern in subject . If any match occurs then it will remove that char > > from > > > subject . so finally , as in our example > > > at end subject ="rdr" > > > > > > void fun(char *subject,char *pattern) > > > { > > > // write your code here} > > > > > > > > > > -- With Best Regards... --------------------- Manish --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---