C#冒泡排序
代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace pop
{
class Program
{
static void Main(string[] args)
{
pop();
}
static void pop()
{
string[] arr1 = Console.ReadLine().Split(' ');
int[] a = new int[10];
for(int i = 0; i < 10; i++)
{
a[i] = int.Parse(arr1[i]);
}
for(int i = 0; i < 9; i++)
{
for(int j = 0; j < 9-i; j++)
{
if (a[j] > a[j + 1])
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
foreach(int s in a)
{
Console.Write(s+" ");
}
Console.WriteLine();
for(int i = 9; i >= 0; i--)
{
Console.Write(a[i] + " ");
}
Console.WriteLine();
}
}
}