using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace MyLunch
{
/// <summary>
/// switch的用法
/// </summary>
///
public class Number
{
ArrayList list = new ArrayList();
int[] intList;
public Number()
{
}
public void Input()
{
Console.WriteLine("這個程序是讓你輸入三個數,然後再按照順序排列出來。(按X退出)");
string Input;
for (; ; )
{
Input = Console.ReadLine();
if ("X" == Input.ToUpper())
break;
else
list.Add(Input);
}
}
public void Sort()
{
intList = new int[list.Count];
Console.WriteLine(list.Count);
//附值.
for (int i = 0; i < list.Count; i++)
{
intList[i] = int.Parse(list[i].ToString());
}
for (int i = 0; i < intList.Length; i++)
{
for (int j = i + 1; j < intList.Length; j++)
{
int temp;
if (intList[i] > intList[j])
{
temp = intList[j];
intList[j] = intList[i];
intList[i] = temp;
}
}
}
}
public void Display()
{
foreach (var item in intList)
{
Console.WriteLine(item.ToString());
}
}
}
class Program
{
static void Main(string[] args)
{
Number number = new Number();
number.Input();
number.Sort();
number.Display();
}
}
}
//另外一個例子。都是蠻簡單的。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("歡迎光臨本商場"+"
"+"你今天花了多少錢啊?");
int input=int.Parse((Console.ReadLine()));
string Display;
if (input<5)
{
Display="你可以走了!";
}
else if(input>5&&input<20)
{
Display="獎勵你一杯咖啡!";
}
else if(input>20&&input<30)
&