代碼圖

效果圖

代碼
int[] shuru = new int[6];
? ? ? ? ? ? int max = 0;
? ? ? ? ? ? try
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int i = 0; i < shuru.Length; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.WriteLine("請(qǐng)輸入第{0}個(gè)整數(shù)",i+1);
? ? ? ? ? ? ? ? ? ? shuru[i] = Convert.ToInt32(Console.ReadLine());
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? for (int i = 0; i < shuru.Length-1; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? for (int j = 0; j < shuru.Length-1-i; j++)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? if (shuru[j]>shuru[j+1])
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? max = shuru[j];
? ? ? ? ? ? ? ? ? ? ? ? ? ? shuru[j] = shuru[j+1];
? ? ? ? ? ? ? ? ? ? ? ? ? ? shuru[j+1] = max;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? for (int i = 0; i < shuru.Length; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("{0}\t",shuru[i]);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? catch
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine("輸入有誤請(qǐng)重新輸入");
? ? ? ? ? ? }
? ? ? ? ? ? Console.ReadKey();