?? 何意數排序.txt
字號:
using System;
public class Test
{
public static void Main()
{
//不知道怎么搞的,兩個不能同進用,想不明白,可能是前一種方法已經把值給改變了
int x;
int temp;
Console.WriteLine ("你想排幾個數的序:");
x=int.Parse (Console.ReadLine ());
int[] array_previous=new int [x];
for(int i=0;i<array_previous.Length;i++)
{
Console.WriteLine ("請輸入第{0}個數:",i+1);
array_previous[i]=int.Parse (Console.ReadLine ());
}
for(int index=1;index<array_previous.Length;index++)
{
if(array_previous[index-1]<array_previous[index])
{
temp=array_previous[index-1];
array_previous[index-1]=array_previous[index];
array_previous[index]=temp;
}
}
Console.WriteLine ("正序排列為:");
foreach(int pin in array_previous)
{
Console.Write (pin+"\t");
}
Console.WriteLine ();
for(int index=1;index<array_previous.Length;index++)
{
if(array_previous[index-1]>array_previous[index])
{
temp=array_previous[index-1];
array_previous[index-1]=array_previous[index];
array_previous[index]=temp;
}
}
Console.WriteLine ("反序排列為:");
foreach(int pin in array_previous)
{
Console.Write (pin+"\t");
}
Console.WriteLine ();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -