用C#编写 任意输入一串英文例如 how are you 最终输出的结果是 you are how 最好能把思路也写给我。

[复制链接]
查看11 | 回复2 | 2012-5-31 02:03:33 | 显示全部楼层 |阅读模式
思路就是:词之间是空格分开的,可以用Split把一整句给断成每个词,放入一个字符串数组中。然后从后往前循环此数组,重组字符串。string str = Console.ReadLine();string[] sarray = str.Split(new char[] {' '});string res = "";for (int i = sarray.Length - 1; i >= 0; i--)
res = res + sarray + " ";Console.WriteLine(res);...
回复

使用道具 举报

千问 | 2012-5-31 02:03:33 | 显示全部楼层
string str = "How are you";string [] strArr=str.Split(' ');int it = strArr.Length - 1;string temp;
for(int i=0;i<=it/2;i++)
{
...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行