如何循环此步骤。 [英] How Do I Loop This Step.
本文介绍了如何循环此步骤。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Console.WriteLine("Please enter Name");
name = Console.ReadLine();
Console.WriteLine("{0} has been stored", name);
Console.WriteLine("Enter the License plate Number");
Console.WriteLine("");
LicenseplateNumber = Console.ReadLine();
int numcar1, numcar2, total, result;
int[] num = new int[2];
num[0] = 1;
num[1] = 2;
Console.WriteLine("Please enter how many cars");
numcar1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Total space=2");
total = 2;
result = total - numcar1;
Console.WriteLine("{0} space is left", result);
好的我已经查看了文章,但仍然无法确定在哪里放置循环。我想循环,以便我可以填写2.当它完成时我如何写空间已满。我写的是什么(结果< = 2)。帮助?
ok i have looked at the articles and still cant figure where to put the loop. I want to loop so that i can fill for 2. and when its done how do i write the space is full. do i write while (result <= 2). help?
推荐答案
它真的取决于你的逻辑以及你想要实现什么样的循环你需要使用的东西 - 以及什么样的'结束'条件你需要 - 也许
it really depends on your logic and what you want to achieve as to what sort of loop you need to use - and what sort of 'end' condition you need - maybe
do
{
// Some Statements
} while (some condition);
是什么你需要,但有点难以分辨
你想要达到什么目的?如果你不能解释你想要做什么,有sfa点问我们在哪里放置循环
is what you need, but its a bit hard to tell
What are you trying to achieve ? there's sfa point asking us where to put the loop if you cant explain what you're trying to do
看看你是否可以填写这里缺少的东西......你在哪里看到??? ? ...并使其有效:
See if you can fill in what's missing here ... where you see ???? ... and make it work:
class Program
{
static int numberOfSpaces = 3;
static int currentCar = 0;
static int spacesFree = numberOfSpaces;
static string[,] currentCarsParked = new string[numberOfSpaces, 2];
static void Main(string[] args)
{
string name, license;
while (spacesFree > 0)
{
Console.Clear();
ReportStatus();
Console.WriteLine();
Console.Write("Please enter Name: ");
name = Console.ReadLine();
Console.Write("Enter the License plate Number: ");
license = Console.ReadLine();
currentCarsParked[????, 0] = name;
currentCarsParked[????, 1] = license;
currentCar++;
spacesFree--;
}
Console.Clear();
Console.WriteLine("Parking Lot is full !");
Console.WriteLine();
ReportStatus();
Console.WriteLine();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static void ReportStatus()
{
Console.Write("Current Parked Cars: {0}", currentCar);
Console.WriteLine(": Spaces available: {0}", spacesFree);
Console.WriteLine();
for (int i = 0; i < ????; i++)
{
Console.Write("Space: {0}: Car #{1}", i + 1, currentCarsParked[i, 0]);
Console.WriteLine(" License: {0}", currentCarsParked[i, 1]);
}
}
}
这篇关于如何循环此步骤。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文