我想由大到小排序~但是有些是不按顺序,我不知道怎样改~
static void Main(string[] args)
{
double t;
double[] x = new double[100];
for (int a = 0; a <= x.Length - 1; a++)
{
x[a] = Math.Sin(a + 1);
}
for (int b = 0; b <= x.Length-1; b++)
{
int max = b;
for (int i=b; i <= x.Length-1; i++)
{
if (x[i]>x[max])
max=i;
t = x[b];
x[b] = x[max];
x[max] = t;
}
}
for (int s = 0; s <= x.Length - 1; s++)
Console.WriteLine(x[s]);
}
------解决方案--------------------
去掉这一段吧,看着不好
for (int a = 0; a < x.Length; a++)
{
Console.WriteLine(x[a]);
}