Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     int dd,mm,yy,ddmax;
  8.     cout<<"Chon ngay : ";
  9.     cin>>dd;
  10.     cout<<"Chon thang : ";
  11.     cin>>mm;
  12.     cout<<"Chon nam : ";
  13.     cin>>yy;
  14.     if ((yy < 0) || (mm > 12) || (dd <  0) || (dd > 31) || (mm < 0))
  15.     cout<<"KHONG HOP LE";
  16.     else
  17.     {
  18.    
  19.      switch (mm)
  20.         {
  21.         case 1:
  22.         case 3:
  23.         case 5:
  24.         case 7:
  25.         case 8:
  26.         case 10:
  27.         case 12:
  28.         ddmax=31;
  29.         break;
  30.         case 2:
  31.             if ((yy % 4 == 0) && (yy % 100 != 0) || (yy % 400 == 0))
  32.             ddmax=29;
  33.             else
  34.             ddmax=28;
  35.         case 4:
  36.         case 6:
  37.         case 9:
  38.         case 11:
  39.          ddmax=30;
  40.          break;
  41.            
  42.         default:
  43.         {
  44.             cout<<"KHONG HOP LE";
  45.         }
  46.         }
  47.         if (dd < ddmax)
  48.         {
  49.             cout<<"Ngay hop le";
  50.         }
  51.         else
  52.         {
  53.             cout<<"Ngay khong hop le";
  54.         }
  55.     }
  56.     getch();
  57.     return  0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement