110,925
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
string str = "cdeapabje";
char[] chars = new char[str.Length];
for (int i = 0; i < str.Length; i++)
{
chars[i] = str[i];
}
for (int i = 0; i < str.Length; i++)
{
for (int j = i + 1; j < str.Length; j++)
{
if (chars[i] > chars[j])
{
char temp = chars[j];
chars[j] = chars[i];
chars[i] = temp;
}
}
}
str = new string(chars);
Console.Write(str);
}
static string StringSort(string str)
{
char[] chars = str.ToCharArray();
Array.Sort(chars);
return new string(chars);
}
char[] chars = str.ToCharArray();
Array.Sort(chars);
return new string(chars);