bool b = true;
Console.WriteLine("\t\t\t\t猜数字游戏");
while(b)
{
Random rd = new Random();
int s = rd.Next(1,100);
int count = 0;
while (true)
{
Console.WriteLine("请输入1-100的数字:");
int n=Convert.ToInt32(Console.ReadLine());
if (n > 100 || n <= 0)
{
Console.WriteLine("傻吗?是1-100,1-100,1-100!");
Console.WriteLine("请重新输入!");
continue;
}
count++;
if (n > s)
{
Console.WriteLine("太大了哦!");
}
else if (n == s)
{
Console.WriteLine("猜对了,你真棒!");
Console.WriteLine("您总共猜了{0}次",count);
switch (count)
{
case 1: Console.WriteLine("评价:S"); break;
case 2: Console.WriteLine("评价:A"); break;
case 3: Console.WriteLine("评价:A-"); break;
case 4: Console.WriteLine("评价:B"); break;
case 5: Console.WriteLine("评价:B-"); break;
case 6: Console.WriteLine("评价:C"); break;
case 7: Console.WriteLine("评价:D"); break;
default: Console.WriteLine("评价:评价是什么你心里没点B数吗?"); break;
}
break;
}
else
{
Console.WriteLine("太小了哦!");
}
}
Console.WriteLine("是否重新开始?是请输入1,否请输入其他。");
count=Convert.ToInt32(Console.ReadLine());
switch(count)
{
case 1: Console.WriteLine("\n\n"); break;
default: b=false;break;
}
}
“蠢是会传染的 你们别靠近我 我机智”
--来自360专用版贴吧客户端
Console.WriteLine("\t\t\t\t猜数字游戏");
while(b)
{
Random rd = new Random();
int s = rd.Next(1,100);
int count = 0;
while (true)
{
Console.WriteLine("请输入1-100的数字:");
int n=Convert.ToInt32(Console.ReadLine());
if (n > 100 || n <= 0)
{
Console.WriteLine("傻吗?是1-100,1-100,1-100!");
Console.WriteLine("请重新输入!");
continue;
}
count++;
if (n > s)
{
Console.WriteLine("太大了哦!");
}
else if (n == s)
{
Console.WriteLine("猜对了,你真棒!");
Console.WriteLine("您总共猜了{0}次",count);
switch (count)
{
case 1: Console.WriteLine("评价:S"); break;
case 2: Console.WriteLine("评价:A"); break;
case 3: Console.WriteLine("评价:A-"); break;
case 4: Console.WriteLine("评价:B"); break;
case 5: Console.WriteLine("评价:B-"); break;
case 6: Console.WriteLine("评价:C"); break;
case 7: Console.WriteLine("评价:D"); break;
default: Console.WriteLine("评价:评价是什么你心里没点B数吗?"); break;
}
break;
}
else
{
Console.WriteLine("太小了哦!");
}
}
Console.WriteLine("是否重新开始?是请输入1,否请输入其他。");
count=Convert.ToInt32(Console.ReadLine());
switch(count)
{
case 1: Console.WriteLine("\n\n"); break;
default: b=false;break;
}
}
“蠢是会传染的 你们别靠近我 我机智”
--来自360专用版贴吧客户端