using System;
using System.Collections.Generic;
using System.Text;
namespace caishuzi
{
class Program
{
static void Main(string[] args)
{
string sTemp, s;
int x, y = 0, z=0;
int iGuess = 0, iCount = 0;
do
{
Console.WriteLine("请猜猜我想到的一个0到100之间的数字: ");
int iNum = new Random().Next() % 100;
iCount = 0;
do
{
sTemp = Console.ReadLine();
try
{
iGuess = Int32.Parse(sTemp);
if (iGuess > iNum)
{
Console.WriteLine("太大");
}
else if (iGuess < iNum)
{
Console.WriteLine("太小");
}
}
catch (Exception e)
{
Console.WriteLine("你输入的'{0}'不是一个有效的整数", sTemp);
}
finally
{
Console.WriteLine("你已经猜测了{0}次", ++iCount);
}
} while (iGuess != iNum);
Console.WriteLine("恭喜你猜对了,这个数字是{0}", iNum);
y++;
z += iCount;
x = iCount / 10;
switch (x)
{
case 1:
case 2:
Console.WriteLine("还行,智商和运气一般般拉");
break;
case 0:
Console.WriteLine("哇~~好象很厉害的样子");
break;
case 3:
Console.WriteLine("...智商和运气一般般拉~加油哦");
break;
case 4:
case 5:
case 6:
case 7:
Console.WriteLine("...建议你多多读下书~~..只是建议而已");
break;
case 8:
case 9:
Console.WriteLine("....无语中~");
break;
default:
break;
}
Console.WriteLine("是否继续?Y/N?");
s = Console.ReadLine();
} while (s == "Y" || s == "y");
Console.WriteLine("您一共猜了{0}局,共计{1}次", y, z);
s=Console.ReadLine();
}
}
}
不过我可是继承了C++强大的力量的哦~~
嘿嘿~呆会研究下类和其他方面的知识~~