Entri blog oleh 97213529 郭益銘

by 97213529 郭益銘 - Isnin, 17 November 2008, 12:49 AM
Sesiapapun di dunia
下載點1:http://moodle.ncnu.edu.tw/file.php/7345/dogC_.zip

下載點2:http://0rz.tw/e9516

//=====================鋪克牌=========================
ArrayList dog = new ArrayList();
int Rand;
Random rnd = new Random();
for (int i = 1; i <= 52; i++) //設定牌的數字
dog.Add(i);
for (int i = 0; i < 52; i++) //發5張牌
{
Rand = rnd.Next(0,dog.Count);
if(Convert.ToInt32(dog[Rand])%4==0)
Console.WriteLine("梅花{0}", Convert.ToInt32(dog[Rand]) % 13+1);
else if (Convert.ToInt32(dog[Rand]) % 4 == 1)
Console.WriteLine("方塊{0}", Convert.ToInt32(dog[Rand]) % 13+1);
else if (Convert.ToInt32(dog[Rand]) % 4 == 2)
Console.WriteLine("紅心{0}", Convert.ToInt32(dog[Rand]) % 13+1);
else if (Convert.ToInt32(dog[Rand]) % 4 == 3)
Console.WriteLine("黑桃{0}", Convert.ToInt32(dog[Rand]) % 13+1);
dog.RemoveAt(Rand);
}
//=====================Random===================
//Random dog = new Random(); //don't in for or while loop
//Console.WriteLine(dog.Next(2)); //0~1
//Console.WriteLine(dog.Next(2,4)); //2~3
//Console.WriteLine(dog.NextDouble()); //0.87..~1 double
//double dog1 = (10 - 2) * dog.NextDouble() + 2;
//Console.WriteLine(dog1.ToString("##.##")); //2~10 double .2
//======================8 to 10 進位=====================
//Console.Write("請輸入數值:");
//string value = Console.ReadLine();
//double sum = 0.0;
//int count = 0;
//if (value.Contains("."))
// count = value.IndexOf('.') - 1;//IndexOf('.')表示陣列第.個
//else
// count = value.Length - 1;
//for (int i = 0; i < value.Length; i++) //n=>10
// if (value[i] != '.')
// sum += Int32.Parse(value[i].ToString()) * Math.Pow(8, count--);
//Console.WriteLine("10進位是 " + sum);//10
////=========================10 TO 8==================
//string[] arr = sum.ToString().Split('.');
//int gg = 8;
//ArrayList dog1 = new ArrayList();
//int left = Int32.Parse(arr[0]);
//while (left != 0)
//{
// dog1.Add(left % gg);
// left /= gg;
//}
//dog1.Reverse();
//if (sum.ToString().Contains("."))
//{
// dog1.Add(".");
// double right = double.Parse("0." + arr[1].ToString());
// for (int i = 0; i < 10; i++)
// {
// if (Math.Floor(right) == Math.Ceiling(right))
// break;
// right = right * gg;
// dog1.Add(Math.Floor(right));
// right = right - Math.Floor(right);
// }
//}
//for (int i = 0; i < dog1.Count; i++)
// Console.Write(dog1[i]);
//=====================尾巴compare======================
//Console.Write("請輸入一個字串: "); //尾巴
//string input = Console.ReadLine();
//Console.Write("請輸入一個字串: ");
//string input2 = Console.ReadLine();

//Console.Write("最大相似尾巴為: ");
//ArrayList dog = new ArrayList();
//for (int i = 1; i < Math.Min(input.Length, input2.Length); i++)
// if (input[input.Length - i] == input2[input2.Length - i])
// dog.Add(input[input.Length - i]);
// else
// break;
//dog.Reverse();
//for (int i = 0; i < dog.Count; i++)
// Console.Write(dog[i]);
//=====================middle===============
//int dog1; //middle
//string[] input = Console.ReadLine().Split(' ');
//dog1 = input.Length / 2;
//if (input.Length % 2 != 0)
// Console.WriteLine(input[dog1]);
//else
// Console.WriteLine((Convert.ToDouble(input[dog1]) + Convert.ToDouble(input[dog1-1])) / 2.0);
//=====================11010 2=>10==============
//char[] input = Console.ReadLine().ToCharArray(); //11010 2=>10
//double sum = 0;
//for (int i = 0; i < input.Length; i++)
//{
// sum += Convert.ToInt32(input[i].ToString()) * Math.Pow(2, input.Length - 1 - i);
//}
//Console.WriteLine(sum);
//=====================char+2 & char-2=============
//char[] input = Console.ReadLine().ToUpper().ToCharArray(); //char+2 & char-2
//int dog = 0;
//if (input[0] == '+')
//{
// for (int i = 1; i < input.Length; i++)
// {
// dog = Convert.ToInt32(input[i]) + 2;
// if (dog > Convert.ToInt32('Z'))
// Console.Write("{0}", Convert.ToChar(Convert.ToInt32('A') + dog - Convert.ToInt32('Z') - 1));
// else
// Console.Write("{0}", Convert.ToChar(dog));
// }
//}
//else if (input[0] == '-')
//{
// for (int i = 1; i < input.Length; i++)
// {
// dog = Convert.ToInt32(input[i]) - 2;
// if (dog < Convert.ToInt32('A'))
// Console.Write("{0}", Convert.ToChar(Convert.ToInt32('Z')-(Convert.ToInt32('A')-dog)+1));
// else
// Console.Write("{0}", Convert.ToChar(dog));
// }
//}

//======================//look look = ok=================
//Console.Write("請輸入你的資料檔 .txt 的位置 ");
//string path = Console.ReadLine();
//StreamReader sr = new StreamReader(@path);

//string all_line = "";
//while (!sr.EndOfStream)
//{
// all_line = sr.ReadLine();
// Console.WriteLine(all_line);
//}
////=============================ReadToEnd=========================
//Console.Write("請輸入你的資料檔 .txt 的位置 ");
//string path = Console.ReadLine();
//StreamReader sr = new StreamReader(@path);
//string all_line = sr.ReadToEnd();
//string[] d = all_line.Split(' ', '\n');
////===========================struct===========================
//struct studentinfo
//{
// public string name;
// public double chi_grad;
// public double eng_grad;
//};
//static void Main(string[] args) //<<<< //{
// studentinfo[] dog = new studentinfo[100];
// double highest = 0, lowest = 201;
// int highsite = 0, lowsite = 0;
// double chinese = 0, english = 0;
// int i;
// for (i=0; true; i++)
// {
// string[] tmp = Console.ReadLine().Split(' ');
// dog[i].name = tmp[0];
// dog[i].chi_grad = Convert.ToDouble(tmp[1]);
// dog[i].eng_grad = Convert.ToDouble(tmp[2]);
// if (dog[i].chi_grad == 0 && dog[i].eng_grad==0)
// break;

// if (dog[i].eng_grad + dog[i].chi_grad > highest)
// {
// highest = dog[i].eng_grad + dog[i].chi_grad;
// highsite = i;
// }
// if (dog[i].eng_grad + dog[i].chi_grad < lowest)
// {
// lowest = dog[i].eng_grad + dog[i].chi_grad;
// lowsite = i;
// Console.WriteLine(lowest);
// }
// chinese += dog[i].chi_grad;
// english += dog[i].eng_grad;
// }
// Console.WriteLine("最高總分的姓名與總成績 : ");
// Console.WriteLine("{0} {1} {2} {3} ", dog[highsite].name, dog[highsite].chi_grad + dog[highsite].eng_grad, dog[highsite].chi_grad, dog[highsite].eng_grad);

// Console.WriteLine("最低總分的姓名與總成績 : ");
// Console.WriteLine("{0} {1} {2} {3} ", dog[lowsite].name, dog[lowsite].chi_grad + dog[lowsite].eng_grad, dog[lowsite].chi_grad, dog[lowsite].eng_grad);

// Console.WriteLine("中文的總平均分數 {0} 分 ", chinese / i);
// Console.WriteLine("英文的總平均分數 {0} 分 ", english / i);
//}
Console.ReadKey();