@sunny k i have seen... On Tue, Jul 12, 2011 at 6:48 PM, sunny agrawal <sunny816.i...@gmail.com>wrote:
> @shilpa > > see some post is hidden > click on hide quoted text to see the complete post .... > > > On Tue, Jul 12, 2011 at 6:46 PM, shilpa gupta <shilpagupta...@gmail.com>wrote: > >> @sunny well this case is not possible i think in any code a braces that >> are opened should be closed...also >> >> >> On Tue, Jul 12, 2011 at 6:43 PM, sunny agrawal >> <sunny816.i...@gmail.com>wrote: >> >>> @Nitish >>> as complete file will be scanned, program is taking care of functions >>> already >>> >>> @shilpa >>> u r wrong !! >>> that part of code is very important >>> >>> else what will be the answer for the following >>> { >>> { >>> >>> } >>> >>> { >>> >>> } >>> >>> { >>> { >>> >>> >>> } >>> } >>> } >>> >>> On Tue, Jul 12, 2011 at 6:39 PM, shilpa gupta >>> <shilpagupta...@gmail.com>wrote: >>> >>>> i think there is no need of this part >>>> >>>> else if(c== '}' ) >>>> { >>>> depth-=1; >>>> } >>>> than there is no need to find out max also >>>> depth will give max itself i think... >>>> >>>> >>>> On Tue, Jul 12, 2011 at 6:32 PM, sunny agrawal <sunny816.i...@gmail.com >>>> > wrote: >>>> >>>>> 1. what if braces occur in comments >>>>> >>>>> and also i think final answer should be 1 less than(dropping { for >>>>> main()) the final count because there is no meaning of scope depth for a >>>>> global variable >>>>> >>>>> >>>>> On Tue, Jul 12, 2011 at 6:22 PM, nicks <crazy.logic.k...@gmail.com>wrote: >>>>> >>>>>> igonre the previous code, here is fully working code......previous one >>>>>> doesn't include check for having { within quotes which should not be >>>>>> counted >>>>>> for scope depth >>>>>> >>>>>> #include<stdio.h> >>>>>> >>>>>> int main() >>>>>> { >>>>>> int depth=0,max=0; >>>>>> char c,temp; >>>>>> while((c=getchar())!=EOF) >>>>>> { >>>>>> if(c== '{' ) >>>>>> { >>>>>> depth+=1; >>>>>> if(depth>max) >>>>>> max=depth; >>>>>> } >>>>>> else if(c== '}' ) >>>>>> { >>>>>> depth-=1; >>>>>> } >>>>>> else if(c=='\"'||c==39) >>>>>> { >>>>>> temp=c; >>>>>> while((c=getchar())!=temp); //skipping all the >>>>>> characters till next quote occurs >>>>>> } >>>>>> } >>>>>> printf("%d\n",max); >>>>>> } >>>>>> >>>>>> 39 is ASCII code for ' >>>>>> it was giving error when i tried to write it like '''.....so i >>>>>> replaced it with its ASCII to save time....someone please suggest the >>>>>> proper >>>>>> way to writing it... >>>>>> >>>>>> the code is working fine for this code as input output is 3......if >>>>>> any constraints are left then please suggest !! >>>>>> >>>>>> On Tue, Jul 12, 2011 at 5:50 PM, nicks <crazy.logic.k...@gmail.com>wrote: >>>>>> >>>>>>> my bad...that should be understood.. >>>>>>> >>>>>>> >>>>>>> On Tue, Jul 12, 2011 at 5:45 PM, Vandana Bachani < >>>>>>> vandana....@gmail.com> wrote: >>>>>>> >>>>>>>> You have the right braces missing, it would result in a 0 depth for >>>>>>>> all cases. (Precedence of != is greater than =) >>>>>>>> >>>>>>>> On Tue, Jul 12, 2011 at 5:41 PM, nicks >>>>>>>> <crazy.logic.k...@gmail.com>wrote: >>>>>>>> >>>>>>>>> i thought of this code......i think it should work.....correct me >>>>>>>>> if i am wrong >>>>>>>>> >>>>>>>>> >>>>>>>>> depth=0;max=0; >>>>>>>>> while(*(*c=getchar()*)*!=EOF) >>>>>>>>> { >>>>>>>>> if(c== '{' ) >>>>>>>>> { >>>>>>>>> depth+=1 >>>>>>>>> if(depth>max) >>>>>>>>> max=depth; >>>>>>>>> } >>>>>>>>> else if(c== '}' ) >>>>>>>>> { >>>>>>>>> depth-=1; >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> >>>>>>>>> On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain < >>>>>>>>> sandeep6...@gmail.com> wrote: >>>>>>>>> >>>>>>>>>> If we just have to give the depth as in count then, I believe we >>>>>>>>>> can use stack to push/pop curly braces. While maintaining the >>>>>>>>>> maximum depth >>>>>>>>>> observed >>>>>>>>>> And if we have to display/print line numbers or code itself, then >>>>>>>>>> converting the code in a tree structure should help. >>>>>>>>>> Each node can contain the line/col position of starting/closing >>>>>>>>>> braces. Each node will have its nested braces as child nodes. >>>>>>>>>> >>>>>>>>>> PS: In either case make sure you ignore comments and strings >>>>>>>>>> literals >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Regards, >>>>>>>>>> Sandeep Jain >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta < >>>>>>>>>> shilpagupta...@gmail.com> wrote: >>>>>>>>>> >>>>>>>>>>> Write down the c code for finding out the maximum scope depth in >>>>>>>>>>> a c >>>>>>>>>>> code. A scope >>>>>>>>>>> depth is increased by one with every '{' and decreases by one >>>>>>>>>>> with >>>>>>>>>>> every '}' >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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 >>>>>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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 >>>>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain < >>>>>>>>> sandeep6...@gmail.com> wrote: >>>>>>>>> >>>>>>>>>> If we just have to give the depth as in count then, I believe we >>>>>>>>>> can use stack to push/pop curly braces. While maintaining the >>>>>>>>>> maximum depth >>>>>>>>>> observed >>>>>>>>>> And if we have to display/print line numbers or code itself, then >>>>>>>>>> converting the code in a tree structure should help. >>>>>>>>>> Each node can contain the line/col position of starting/closing >>>>>>>>>> braces. Each node will have its nested braces as child nodes. >>>>>>>>>> >>>>>>>>>> PS: In either case make sure you ignore comments and strings >>>>>>>>>> literals >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Regards, >>>>>>>>>> Sandeep Jain >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta < >>>>>>>>>> shilpagupta...@gmail.com> wrote: >>>>>>>>>> >>>>>>>>>>> Write down the c code for finding out the maximum scope depth in >>>>>>>>>>> a c >>>>>>>>>>> code. A scope >>>>>>>>>>> depth is increased by one with every '{' and decreases by one >>>>>>>>>>> with >>>>>>>>>>> every '}' >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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 >>>>>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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 >>>>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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 >>>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> 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 >>>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>> -- >>>>>> 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 >>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Sunny Aggrawal >>>>> B-Tech IV year,CSI >>>>> Indian Institute Of Technology,Roorkee >>>>> >>>>> -- >>>>> 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 >>>>> algogeeks+unsubscr...@googlegroups.com. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> shilpa gupta >>>> b tech 2nd year >>>> computer science and engineering >>>> mnnit allahabad >>>> >>>> -- >>>> 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 >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Sunny Aggrawal >>> B-Tech IV year,CSI >>> Indian Institute Of Technology,Roorkee >>> >>> -- >>> 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 >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> shilpa gupta >> b tech 2nd year >> computer science and engineering >> mnnit allahabad >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > -- > 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 > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- shilpa gupta b tech 2nd year computer science and engineering mnnit allahabad -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.