Input : The quick brown fox jumps over the lazy dog.
Output : dog. lazy the over jumps fox brown quick The 

解决方案 »

  1.   

    string a="The quick brown fox jumps over the lazy dog.";
    string[] arr = a.Split(' ');
    Array.Reverse(arr);
            Console.WriteLine(string.Join(" ",arr));
      

  2.   

    难道楼主是想要一个字母一个字母的分析? private string ReverseString(string sentence)
    {
    string temp=string.Empty;
    string result=string.Empty;
    foreach(char ch in sentence)
    {
    if(ch==' ')
    {
    result=temp+" "+result;
    temp="";
    }
    else temp+=ch.ToString();
    }
    result=temp+" "+result;
    return result;
    }
      

  3.   

    先这样看看,楼主找给测试速度的方法,比较一下
    private string Reverse(string str)
    {
        char[] src = str.ToCharArray();
        char[] result = new char[str.Length];
        int j = 0;
        for (int i = 0; i <= str.Length; i++)
        {
            if (i == str.Length || src[i] == ' ')
            {
                Array.Copy(src, j, result, str.Length - i, i - j);
                if (i < str.Length) result[str.Length - i - 1] = ' ';
                j = i + 1;
            }
        }    return new string(result);
    }private void button1_Click(object sender, EventArgs e)
    {
        string s = "The quick brown fox jumps over the lazy dog.";
        Console.WriteLine(Reverse(s));
    }
      

  4.   

    string a="The quick brown fox jumps over the lazy dog.";
            string[] arr = a.Split(' ');
            Array.Reverse(arr);
            Console.WriteLine(string.Join(" ",arr));