我是菜鸟,然后编了一个关于输入整数排序输出跟输入字符串倒序输出的代码出错了,不知道怎么改,求救!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 排序sort
{
class Program
{
static void Main(string[] args)
{
int[] arr = { 3, 1, 2, 8 };
sort(arr);
string[] str = { hello };
sort(str);
}
class sort
{
public void sort(int[] array)
{
int t;
for (int i = array.Length; i > 0; i--)
{
for (int j = 0; j < i; j++)
{
if (array[j] > array[j + 1])
{
t = array[j];
array[j] = array[j + 1];
array[j + 1] = t;
}
}
}
for (int k = 0; k < array.Length; k++)
{
Console.Write("{0},", array[k]);
}
}
public void sort(string[] s)
{
for (int i = s.Length; i > 0; i--)
{
Console.Write("{0}", s[i]);
}
}
}
}
}