适合新手的案例

 class Program
{
static void Main(string[] args)
{
//投掷子的游戏
Console.WriteLine("Today,we play one game:");
Console.WriteLine("_________________________________________By Mr.w");

for (int i = 0; i < 10; i++)
{
Console.Write("*");
Thread.Sleep(500);//让程序在这个时候停顿0.5秒
}

Console.WriteLine("The game is staring!");

Random rannum = new Random();

//第一个数:
Console.WriteLine("please waiting....catching the first number");
for (int a = 0; a < 5; a++)
{

Console.Write("*");
Thread.Sleep(500);//让程序在这个时候停顿0.5秒
}
Console.WriteLine();
int i1 = rannum.Next(1, 6);
Console.WriteLine("The first number is {0}", i1);


//第二个数字:
Console.WriteLine("please waiting....catching the second number");
for (int i = 0; i < 5; i++)
{

Console.Write("*");
Thread.Sleep(500);//让程序在这个时候停顿0.5秒
}
Console.WriteLine();
int i2 = rannum.Next(1, 6);
Console.WriteLine("The second number is {0}", i2);


int sum = i1 + i2;
Console.WriteLine("The Sum number is {0}", sum);



if (sum == 7 || sum == 11)
{
Console.WriteLine("congration to Gamer!");
}

if (sum == 2 || sum == 3 || sum == 11)
{
Console.WriteLine("sorry,you are lose.");
}

if (sum == 4 || sum == 5 || sum == 6 || sum == 8 || sum == 9 || sum == 10)
{
int temp=sum;
Console.WriteLine("The Sum number is {0}", temp);
Console.WriteLine("please go on catching...and the next number equal to Sum");
for (int s = 0; s <= 3; s++)
{

i1 = rannum.Next(1, 6);
Console.WriteLine("The first number is {0}", i1);

i2 = rannum.Next(1, 6);
Console.WriteLine("The second number is {0}", i2);
sum = i1 + i2;
Console.WriteLine("The Sum number is {0}", sum);


if (sum == temp)
{
Console.WriteLine("The Gamer is Winer!");
return;
}

if (sum == 7)
{
Console.WriteLine("you are loser!");
return;
}
}
}
}
}
posted @ 2011-12-13 16:53  Anleb  阅读(279)  评论(0编辑  收藏  举报