[algogeeks] Re: output
Printf will print one value per item in the format string. If you don't supply that many, it will look at the undefined memory where that value should have been, so you will get gibberish. Don On Friday, December 6, 2013 9:17:36 AM UTC-5, segfault wrote: > > Hi All, > > I'm not able to get output of following c program : > > #include > main() > { > int a[] ={ 1,2,3,4,5,6,7}; > char c[] = {'a','x','h','o','k'}; > //printf("%u %u\n", &a[3], &a[0]); line 6 > printf("%d %d %d %d \n", (&a[3]-&a[0])); > } > > If line 6 is commented, output : > > 3 1562814827 1869117537 0 > > Confusion : why is there 4 output? "(&a[3]-&a[0])" should give only one. > > if line 6 is not commented, output : > > 1554221244 1554221232 > 3 1554221232 1309214001 64 > > > > Can anybody please explain why/how these outputs are coming? > > Thanks, > Pawan. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
[algogeeks] Re: Modified String Searching
Guneesh Paul Singh writes: > > > This is a test This is a programming test This is a programming test in any language > 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 (count of this) > > > 0 0 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 (count of a) > > > 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 (count of test) > > > 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 (count of programming) > > > 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (index) > > > now we need to select 2 indexes such tha the diff array i greater or equal to [1,1,1,1] > > (0,7) (1,7) (6,9) etc are some solout of which (6,9) is min > > > I happened to come across this solution, and i dnt understand how u pick those two indices. can u plz elaborate on that procedure? Thanks. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] output
i think because of &operator the program is working differently... also there is four data value print operation.. On Mon, Dec 9, 2013 at 2:34 AM, Tamanna Afroze wrote: > I got some other outputs.. when line 6 isn't commented i got 3 1 2 3, i m > using turbo c++ compiler.. > > > On Fri, Dec 6, 2013 at 8:17 AM, pawan yadav wrote: > >> Hi All, >> >> I'm not able to get output of following c program : >> >> #include >> main() >> { >> int a[] ={ 1,2,3,4,5,6,7}; >> char c[] = {'a','x','h','o','k'}; >> //printf("%u %u\n", &a[3], &a[0]); line 6 >> printf("%d %d %d %d \n", (&a[3]-&a[0])); >> } >> >> If line 6 is commented, output : >> >> 3 1562814827 1869117537 0 >> >> Confusion : why is there 4 output? "(&a[3]-&a[0])" should give only one. >> >> if line 6 is not commented, output : >> >> 1554221244 1554221232 >> 3 1554221232 1309214001 64 >> >> >> >> Can anybody please explain why/how these outputs are coming? >> >> Thanks, >> Pawan. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to algogeeks+unsubscr...@googlegroups.com. >> > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] output
I got some other outputs.. when line 6 isn't commented i got 3 1 2 3, i m using turbo c++ compiler.. On Fri, Dec 6, 2013 at 8:17 AM, pawan yadav wrote: > Hi All, > > I'm not able to get output of following c program : > > #include > main() > { > int a[] ={ 1,2,3,4,5,6,7}; > char c[] = {'a','x','h','o','k'}; > //printf("%u %u\n", &a[3], &a[0]); line 6 > printf("%d %d %d %d \n", (&a[3]-&a[0])); > } > > If line 6 is commented, output : > > 3 1562814827 1869117537 0 > > Confusion : why is there 4 output? "(&a[3]-&a[0])" should give only one. > > if line 6 is not commented, output : > > 1554221244 1554221232 > 3 1554221232 1309214001 64 > > > > Can anybody please explain why/how these outputs are coming? > > Thanks, > Pawan. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.