单词逆序输出问题!

newcomer123 2008-07-17 12:51:21
如 i am a student , 输出 student a am i
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdgphc 2008-07-17
  • 打赏
  • 举报
回复
Array.Reverse(words);
原来可以这样啊,学习ing
jinjazz 2008-07-17
  • 打赏
  • 举报
回复
string str = "i am a student ";
string[] temp = str.Split(' ');

for (int i = temp.Length - 1; i >= 0; i--)
{
Console.Write("{0} ", temp[i]);
}
Console.Read();
gomoku 2008-07-17
  • 打赏
  • 举报
回复

string s = "I am a student";
string[] words = s.Split(' ');
Array.Reverse(words);
string result = string.Join(" ", words);
颤菊大师 2008-07-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gomoku 的回复:]
C# code
string s = "I am a student";
string[] words = s.Split(' ');
Array.Reverse(words);
string result = string.Join(" ", words);
[/Quote]

学习啊!哇!
pupo 2008-07-17
  • 打赏
  • 举报
回复
private string Reverse(string s)
{
char[] cs = s.ToCharArray();
int end = s.Length - 1;
int length = 0;
string result = string.Empty;
while(end >= 0)
{
while(end >= 0 && cs[end] != ' ')
{
length++;
end --;
}
result += new string(cs, end+1, length);
result += " ";
length = 0;
end --;
}
return result;
}
zzyhuian06142 2008-07-17
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jinjazz 的回复:]
C# codestring str = "i am a student ";
string[] temp = str.Split(' ');

for (int i = temp.Length - 1; i >= 0; i--)
{
Console.Write("{0} ", temp[i]);
}
Console.Read();
[/Quote]
这个
newcomer123 2008-07-17
  • 打赏
  • 举报
回复
谁能给整个不用系统函数的阿!

110,011

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧