在控制台中为用户编号输入设置最大和最小值
Console.WriteLine(" **************************************");
Console.WriteLine(" ****** Reviewer Awarding Points ******");
Console.WriteLine(" **************************************");
Console.WriteLine();
string[]properties= { "Clarity", "Orginality", "Difficulty" };
int[] a = new int[3];
int[] b = new int[3];
for(int i = 0; i < 3; i++)
{
Console.WriteLine(" ***" + properties[i]+"***");
Console.Write(" Alice: ");
a[i] = Convert.ToInt16(Console.ReadLine());
if(a[i]>100 || a[i] < 1)
Console.Write(" Bob: ");
b[i] = Convert.ToInt16(Console.ReadLine());
Console.WriteLine();
}
Console.Read();
}
我希望用户输入1到100之间的值(包括1和100)。那么我要做什么?
Console.WriteLine(" **************************************");
Console.WriteLine(" ****** Reviewer Awarding Points ******");
Console.WriteLine(" **************************************");
Console.WriteLine();
string[]properties= { "Clarity", "Orginality", "Difficulty" };
int[] a = new int[3];
int[] b = new int[3];
for(int i = 0; i < 3; i++)
{
Console.WriteLine(" ***" + properties[i]+"***");
Console.Write(" Alice: ");
a[i] = Convert.ToInt16(Console.ReadLine());
if(a[i]>100 || a[i] < 1)
Console.Write(" Bob: ");
b[i] = Convert.ToInt16(Console.ReadLine());
Console.WriteLine();
}
Console.Read();
}
I want user to enter a value between 1 and 100(including 1 and 100).So what I am gonna do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题不清楚
尝试
your question is not clear
try
制作一种检查范围内结果的方法:
逃脱循环的唯一方法是输入范围内的有效数字,否则问题只能重复,
然后您可以在代码中多次使用它:
Make a method that checks the result for being in range:
The only way to escape the loop is to enter a valid number that is in range, otherwise the question just repeats
Then you can use it multiple times in your code:
Try this:
You can learn about C# operators at this site: https://www.w3schools.com /CS/cs_operators.php
Try this:
You can learn about C# operators at this site: https://www.w3schools.com/cs/cs_operators.php