Witam serdecznie.
Mój program, posiada trzy funkcje typu bool
bool IsValidDate(struct date a)
{
if (a.month > 0 && a.month<13 && a.day>0 && a.day < 32)
{
return true;
}
else
{
return false;
}
}
bool IsValidDate2(struct date a)
{
if (a.month == 2 && a.day == 30 || a.day == 31 && a.month == 4 && a.day == 31 || a.month == 6 && a.day == 31 || a.month == 9 && a.day == 31 || a.month == 11 && a.day == 31)
{
return false;
}
else
{
return true;
}
}
bool IsLeapYear(struct date a)
{
if (a.year % 4 == 0 && a.year % 100 != 0 || a.year % 400 == 0)
{
return true;
}
else
{
return false;
}
}
bool IsValidDate3(struct date a)
{
if (a.year % 4 == 0 && a.year % 100 != 0 || a.year % 400 == 0) // I tried to use function IsLeapYear, but I had error(not declared birthday), so I don't have a better idea to do it in another way.
{
if (a.month == 2 && a.day == 29)
{
return false;
}
return true;
}
else
{
return true;
}
IsValidDate - dba o to, aby użytkownik nie podał nieistniejącego miesiąca, lub ilości jego dni.
IsValidDate2 - z dokładnością dba o niektóre miesiące.
IsValidDate3 - Dba o to, aby w rok przestępnym luty mógł mieć 29 dni.
IF: Wygląda tak:
if (IsValidDate(birthday) && IsValidDate2(birthday) && IsValidDate3(birthday))
{
ShowDate(birthday);
}
else
{
printf("BAD DATE!!\n");
}
Czy ktoś mógłby mnie nakierować, gdzie popełniam błąd?
Z góry bardzo dziękuję.
Pozdrawiam!