在网上看到一个关于返转字符的贴子。要求如下。
比如输入:“I am   a     Programer”
要求输出:“Programer     a   am I”自己也写了一下,代码如下。经过测试好象没有问题,但是代码应该是有问题的,自己没发现,请各位帮忙测试下,这样写可不可以。
        private void button1_Click(object sender, EventArgs e)
        {
            string oldstr = textBox1.Text;
            string[] temp = oldstr.Split(' ');            string[] newstr = new string[temp.Length];            for (int i = 0; i <temp.Length; i++)
            {
                newstr[temp.Length-i-1] = temp[i];
            }
            string s=null;
            for (int i = 0; i < newstr.Length; i++)
            { s = s + newstr[i] + "*"; //我用*号来显示空格}
            textBox2.Text=s.Substring(0,s.Length-1);//这里后面的减一是因为测试时输出时后面多了一个空格
        }
    }