recursive version of the code
void rev(char *beg, char *end)
{
if(beg<=end)
rev(beg+1, end-1);
else
return ;
swap(beg,end);
}
On Wed, Jun 1, 2011 at 5:46 PM, saurabh singh <[email protected]> wrote:
>
> Tho a do while loop in place of the second while loop will do equally good.
>
> On Wed, Jun 1, 2011 at 5:45 PM, saurabh singh <[email protected]> wrote:
>
>>
>> Ya thanks.....
>>
>> On Wed, Jun 1, 2011 at 5:35 PM, rohit <[email protected]> wrote:
>>
>>> @saurabh singh
>>> one lil addition make your code complete.
>>>
>>> #include<stdio.h>
>>> #include<conio.h>
>>>
>>> int main()
>>> {
>>> char s[20],t[30],*p,*q;
>>> scanf("%s",s);
>>> p=s;
>>> q=t;
>>> while(*(++p)!='\0');
>>> p--;
>>> while(p!=s)
>>> {
>>> *(q++)=*(p--);
>>> }
>>> *(q++)=*(p--); // first character of string
>>> *q='\0';
>>> printf("%s",t);
>>> getch();
>>> return 0;
>>> }
>>>
>>>
>>>
>>> On May 28, 4:25 pm, saurabh singh <[email protected]> wrote:
>>> > #include<stdio.h>
>>> > int main()
>>> > {
>>> > char s[20],t[30],*p,*q;
>>> > scanf("%s",s);
>>> > p=s;
>>> > q=t;
>>> > while(*(++p)!='\0');
>>> > p--;
>>> > while(p!=s)
>>> > {
>>> > *(q++)=*(p--);
>>> > }
>>> > *q='\0';
>>> > }
>>> > Is this what you are looking for?
>>> > I think an inplace solution is required?
>>> >
>>> > On Sat, May 28, 2011 at 4:10 PM, abc abc <[email protected]>
>>> wrote:
>>> > > *Given an array of characters. How would you reverse it. ? How would
>>> you
>>> > > reverse it without using indexing in the array.*
>>> > > *
>>> > > *
>>> >
>>> > > --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > "Algorithm Geeks" group.
>>> > > To post to this group, send email to [email protected].
>>> > > To unsubscribe from this group, send email to
>>> > > [email protected].
>>> > > For more options, visit this group at
>>> > >http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > --
>>> > Saurabh Singh
>>> > B.Tech (Computer Science)
>>> > 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>>
>
>
> --
> Saurabh Singh
> B.Tech (Computer Science)
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.