usingSystem; usingSystem.Collections.Generic; usingSystem.Text; namespaceConsoleApplication1 {
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceConsoleApplicat...
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
namespaceConsoleApplication1
{
classProgram
{
staticvoidMain(string[] args)
{
intmidnumber = 0, getnumber = 0, stop = 1, counter = 0 ;
stringstr="这是个以内的整数猜数字游戏!\n请输入所猜的数值:";
Console.WriteLine(str);
Randomrdn = newRandom();//产生一个新随机数对象
midnumber =rdn.Next(100);//取以内的整数
while(stop == 1)
{
counter++;
getnumber = int.Parse(Console.ReadLine());
if(getnumber< 1 || getnumber > 100)
{
Console.WriteLine("您输入的整数{0}不在范围内,请重新输入!",getnumber);
}
if(getnumber > midnumber)
{
Console.WriteLine("您输入的整数"+getnumber+"偏大,请重新输入!");
}
elseif(getnumber ==midnumber)
{
Console.WriteLine("恭喜你,猜对了!\n您共猜了"+counter+"次。");
Console.WriteLine("请输入-1来结束游戏。");
stop = int.Parse(Console.ReadLine());
}
else
{
Console.WriteLine("您输入的整数"+getnumber+"偏小,请重新输入!");
}
}
}
}
}
第八行staticvoidMain处提示类、结构或接口方法必须有返回类型,求解啊求解 展开
usingSystem.Collections.Generic;
usingSystem.Text;
namespaceConsoleApplication1
{
classProgram
{
staticvoidMain(string[] args)
{
intmidnumber = 0, getnumber = 0, stop = 1, counter = 0 ;
stringstr="这是个以内的整数猜数字游戏!\n请输入所猜的数值:";
Console.WriteLine(str);
Randomrdn = newRandom();//产生一个新随机数对象
midnumber =rdn.Next(100);//取以内的整数
while(stop == 1)
{
counter++;
getnumber = int.Parse(Console.ReadLine());
if(getnumber< 1 || getnumber > 100)
{
Console.WriteLine("您输入的整数{0}不在范围内,请重新输入!",getnumber);
}
if(getnumber > midnumber)
{
Console.WriteLine("您输入的整数"+getnumber+"偏大,请重新输入!");
}
elseif(getnumber ==midnumber)
{
Console.WriteLine("恭喜你,猜对了!\n您共猜了"+counter+"次。");
Console.WriteLine("请输入-1来结束游戏。");
stop = int.Parse(Console.ReadLine());
}
else
{
Console.WriteLine("您输入的整数"+getnumber+"偏小,请重新输入!");
}
}
}
}
}
第八行staticvoidMain处提示类、结构或接口方法必须有返回类型,求解啊求解 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询