Given three natural numbers a, b, c which represent the day, month and year of some date. output “yes"

if the given date is correct and “no” otherwise.с++​

darya21072005 darya21072005    2   03.10.2019 13:57    191

Ответы
liana5101 liana5101  09.10.2020 14:22

#include <iostream>

using namespace std;

int main()

{

 int a, b, c, febrary;

 bool isValid;

 //setlocale(LC_ALL, "Russian");

 cout << "Day:";

 cin >> a;

 cout << "Month:";

 cin >> b;

 cout << "Year:";

 cin >> c;

 if (c % 4 == 0)

   febrary = 29;

 else

   febrary = 28;

 isValid = true;

 if (b < 1 || b > 12)

   isValid = false;

 if (a < 1 || b > 31)

   isValid = false;

 if (b == 4 || b == 6 || b == 9 || b == 11)

   isValid = false;

 if (b == 2 && a > febrary)

   isValid = false;

 if (isValid)

   cout << "yes";

 else

   cout << "no";

}

ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика