On Tue, Jun 28, 2011 at 3:04 PM, sagar pareek <sagarpar...@gmail.com> wrote:
> I have 1 more solution :-
>
> #include<stdio.h>
> #include<string.h>
>
> main()
> {
>  int i,j,l;
>  char arr[100];
>  printf("Enter the string\n");
>  fgets(arr,100,stdin);
>
>  for(i=0,l=strlen(arr),j=l;i<=l/2;i++)
>  {
>   arr[j--]=arr[i];
>   arr[i]=arr[j];
>  }
>
>  for(i--;i<l;i++)
>  arr[i]=arr[i+1];
>
>  arr[i]='\0';
>
>  printf("%s\n",arr);
> }
>
> I hope it will work perfect :)

it works, but it does need extra space to swap variables, it uses '\0' space.
personally speaking, I prefer to use XOR, it is so cool.  :-)
-- 
Regards
Anders

-- 
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.

Reply via email to