一哄尔、
Console.WriteLine("歡迎進入魔法游戲廳");
Console.WriteLine("請選擇您喜愛的游戲:");
Console.WriteLine("****************************************");
Console.WriteLine(@"
1.斗地主
2.斗牛
3.泡泡龍
4.連連看");
Console.WriteLine("****************************************");
Console.Write("請選擇:");
string str_num = Console.ReadLine();
try
{
int num = Convert.ToInt32(str_num);
switch (num)
{
case 1:
Console.WriteLine("您已進入斗地主房間");
break;
case 2:
Console.WriteLine("您已進入斗牛房間");
break;
case 3:
Console.WriteLine("您已進入泡泡龍房間");
break;
case 4:
Console.WriteLine("您已進入連連看房間");
break;
}
}
catch
{
Console.WriteLine("你輸入的是非數(shù)字郑气,程序退出芽偏,請重新運行程序");
}
Console.ReadKey();
二、
int n = 1;
int count = 0;
string answer = "";
do { Console.Write("您正在玩第{0}局名眉,成績?yōu)椋?, n);
string str_score = Console.ReadLine();
int score = Convert.ToInt32(str_score);
if (score > 80)
{
count++;
}
n++;
if (n > 5)
{
Console.WriteLine("游戲結(jié)束");
}
else
{
Console.Write("\n繼續(xù)玩下一局嗎?(yes/no)");
answer = Console.ReadLine();
if ("no" == answer)
{
Console.Write("\n您已經(jīng)中途退出程序了");
break;
}
else
{
Console.WriteLine("進入一局");
}
}
}
while (n <= 5);
double rate = count / 5.0;
if (n > 5)
{
if (rate > 0.8)
{
Console.WriteLine("恭喜粟矿,通過一級");
}
else if (rate > 0.6)
{
Console.WriteLine("通過二級");
}
else
{
Console.WriteLine("\n對不起,你未能晉級损拢,繼續(xù)加油吧~");
}
}
else
{
Console.WriteLine("對不起陌粹,你沒有完成游戲,不能晉級福压,繼續(xù)加油努力");
}
Console.ReadKey();