C#的有人會嗎?輸入數值,排序後遞增輸出
B 岡山殺神
發表日期:2007-04-20 13:26:12
B Google
贊助廣告
發表日期:2008-12-06 01:55:07 (
樓)
B 風城遊子~
發表日期:2007-04-21 13:16:13 ( 1 樓)
B 岡山殺神
發表日期:2007-04-23 11:45:26 ( 2 樓)
B 風城遊子~
發表日期:2007-04-23 12:53:02 ( 3 樓)
B 岡山殺神
發表日期:2007-04-23 13:16:42 ( 4 樓)
B 風城遊子~
發表日期:2007-04-23 22:54:18 ( 5 樓)
B 岡山殺神
發表日期:2007-04-24 12:38:47 ( 6 樓)
B 風城遊子~
發表日期:2007-04-26 06:04:20 ( 7 樓)
B 岡山殺神
發表日期:2007-04-27 00:09:10 ( 8 樓)
B 風城遊子~
發表日期:2007-04-27 03:52:00 ( 9 樓)
B 風城遊子~
發表日期:2007-04-27 04:26:49 ( 10 樓)
跑跑看吧~~
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleTWbbs
{
class Program
{
static void Main(string[] args)
{
Program run = new Program();
run.Interaction();
}
private void Interaction()
{
try
{
Console.WriteLine("請輸入任意個非零整數,並以" + " , " + "符號隔開!");
Console.Write("請輸入: ");
string sLine = Console.ReadLine();
string[] split = sLine.Split(',');
int[] IntArray = new int[split.Length];
for (int i = 0; i < IntArray.Length; i++)
{
IntArray[i] = Convert.ToInt32(split[i]);
}
Console.WriteLine("n");
Console.WriteLine("你輸入的值為: ");
for (int j = 0; j < IntArray.Length; j++)
{
Console.Write(IntArray[j] + "|");
}
Console.WriteLine("n");
Array.Sort(IntArray);
Console.WriteLine("值從小到大之排列為: ");
for (int i = 0; i < IntArray.Length; i++)
{
Console.Write(IntArray[i] + "|");
}
Console.WriteLine("n請按任意鍵離開...");
Console.Read();
}
catch (FormatException)
{
Console.WriteLine("錯誤! 請依照指示輸入值!!!n");
Interaction();
}
catch (OverflowException)
{
Console.WriteLine("錯誤! 請依照指示輸入值!!!n");
Interaction();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleTWbbs
{
class Program
{
static void Main(string[] args)
{
Program run = new Program();
run.Interaction();
}
private void Interaction()
{
try
{
Console.WriteLine("請輸入任意個非零整數,並以" + " , " + "符號隔開!");
Console.Write("請輸入: ");
string sLine = Console.ReadLine();
string[] split = sLine.Split(',');
int[] IntArray = new int[split.Length];
for (int i = 0; i < IntArray.Length; i++)
{
IntArray[i] = Convert.ToInt32(split[i]);
}
Console.WriteLine("n");
Console.WriteLine("你輸入的值為: ");
for (int j = 0; j < IntArray.Length; j++)
{
Console.Write(IntArray[j] + "|");
}
Console.WriteLine("n");
Array.Sort(IntArray);
Console.WriteLine("值從小到大之排列為: ");
for (int i = 0; i < IntArray.Length; i++)
{
Console.Write(IntArray[i] + "|");
}
Console.WriteLine("n請按任意鍵離開...");
Console.Read();
}
catch (FormatException)
{
Console.WriteLine("錯誤! 請依照指示輸入值!!!n");
Interaction();
}
catch (OverflowException)
{
Console.WriteLine("錯誤! 請依照指示輸入值!!!n");
Interaction();
}
}
}
}
B 風城遊子~
發表日期:2007-04-27 04:28:53 ( 11 樓)
B 風城遊子~
發表日期:2007-04-27 04:30:07 ( 12 樓)
B -瘋狂哈拉會-
發表日期:2008-03-21 12:29:00 ( 13 樓)
0人
推薦此文章
您可能對這些文章感興趣:
- 上一頁
- 1
- 下一頁
| 注意:非註冊用戶沒有發表文章的權利。 | |


04-01 19:32 最後編輯 |