int monthentered = 0;
int dayentered = 0;
int year = 0000;
int [] month = new int [12];
int [] day = new int [31];
bool leap = false;
for (int x = 0; x <= 11; x++)
{
month[x] = x+1;
}
for (int x = 0; x <= 30; x++)
{
day[x] = x+1;
}
Console.WriteLine("Please enter a year...");
year = (Convert.ToInt16(Console.ReadLine()));
Console.WriteLine("{0}", year);
Console.WriteLine("Please enter a month...");
monthentered = (Convert.ToInt16(Console.ReadLine()));
Console.WriteLine("Please enter a day...");
dayentered = (Convert.ToInt16(Console.ReadLine()));
while (monthentered == 01 || 03 || 05 || 07 || 08 || 10 || 12)
{
while (dayentered == 31)
{
Console.WriteLine("There are only 30 days in this month please re-enter your day...");
dayentered = (Convert.ToInt16(Console.ReadLine()));
}
}
while (monthentered == 02)
{
while (dayentered > 28)
{
Console.WriteLine("There are only 28 days in this month please re-enter your day...");
dayentered = (Convert.ToInt16(Console.ReadLine()));
}
}
Console.WriteLine("{0}/{1}/{2}", dayentered, monthentered, year);
Console.ReadKey();
while (monthentered == 01 || 03 || 05 || 07 || 08 || 10 || 12)
에 문제가 있습니까? 내가 이해하지 못하는 오류가 발생합니다. "Operator '||' cannot be applied to operands of type 'bool' and 'int'"
내 "while"문에 문제가 있습니까
도와주세요.
그런 식으로 작성하는 것이 아닙니다. 나는 당신이'if (montheentered == 01) 또는 (monthentered == 02) 또는 ...)'와 동등한 시도를한다고 가정한다. –