using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;//引用命名空间
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入6个整数,我们将对它进行排序:");
int[] myintArray = new int[6];
for (int i = 0; i <= myintArray.Length - 1; i++) myintArray[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("您输入的数字为:");
foreach (int outint in myintArray) Console.Write(outint +"\t");
Console.WriteLine("降序排序为:");
for(int i=0;i<myintArray.Length-1;i++)
{
int temp;
for(int j=0;j<myintArray.Length-1-i; j++)
{
//降序排序
if(myintArray[j]<myintArray[j+1])
{
temp = myintArray[j];
myintArray[j] = myintArray[j+1];
myintArray[j+1] = temp;
}
}
}
foreach (int outint in myintArray) Console.WriteLine(outint);
Console.ReadKey();
}
}
}
这是我看了背了写了无数遍的冒泡法。
经典永恒。