Hope this logic looks better.
class Program
    {
        static void Main(string[] args)
        {
            string str = "string";
            char[] char_str=str.ToCharArray();
            char temp;
            int string_length = char_str.Length;
            int mid = string_length / 2;
            int j=0;
            for(int i=0;i<mid;i++){
                j = str.Length-1-i;
                temp = char_str[i];
                char_str[i] = char_str[j];
                char_str[j] = temp;
            }

                Console.Write(char_str.ToString());

            Console.Read();
        }
    }

On Sat, May 28, 2011 at 7:53 AM, <adityasir...@gmail.com> wrote:

> In java you can do this, take O(n) time. Is that correct?
>
> -Adi
>
> public class ReverseString {
>
> public static void main(String[] args){
>  String name = "Aditya";
> String reverse = "";
>  for(int i=0;i<name.length();i++){
>
>       System.out.println(name.charAt(i) + reverse);
>       reverse = name.charAt(i) + reverse;
>       }
> }
> }
>
>
> On Sat, May 28, 2011 at 6:40 AM, abc abc <may.i.answ...@gmail.com> 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 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.
>



-- 
Jyothi

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