Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 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, i, k;
  8.     cout<<"Chon nam : ";
  9.     cin>>yy;
  10.     cout<<"Chon thang : ";
  11.     cin>>mm;
  12.     if ((yy < 0) || (mm > 12) || (dd <  0) || (dd > 31) || (mm < 0))
  13.     cout<<"KHONG HOP LE";
  14.     else
  15.     {
  16.    
  17.      switch (mm)
  18.         {
  19.         case 1:
  20.         case 3:
  21.         case 5:
  22.         case 7:
  23.         case 8:
  24.         case 10:
  25.         case 12:
  26.         ddmax=31;
  27.         {
  28.             cout<<"Nhap vao ngay bat ki : ";
  29.             cin>>i;
  30.         if (i < ddmax )
  31.         {
  32.        
  33.             k=i+1;
  34.             cout<<"ngay tiep theo la : "<< k;
  35.         }
  36.         else
  37.         cout<<"LOI" ;
  38.        
  39.         }
  40.         break;
  41.         case 2:
  42.             if ((yy % 4 == 0) && (yy % 100 != 0) || (yy % 400 == 0))
  43.             ddmax=29;
  44.             else
  45.             ddmax=28;
  46.             {
  47.         cout<<"Nhap vao ngay bat ki : ";
  48.             cin>>i;
  49.          if (i < ddmax )
  50.         {
  51.            
  52.             k=i+1;
  53.             cout<<"ngay tiep theo la : "<< k;
  54.         }
  55.         else
  56.         {
  57.             cout<<"LOI" ;
  58.         }
  59.     }
  60.         case 4:
  61.         case 6:
  62.         case 9:
  63.         case 11:
  64.          ddmax=30;
  65.          break;
  66.          {
  67.             cout<<"Nhap vao ngay bat ki : ";
  68.             cin>>i;
  69.          if (i < ddmax )
  70.         {
  71.             k=i+1;
  72.             cout<<"ngay tiep theo la : "<< k;
  73.         }
  74.         else
  75.         {
  76.             if (i == ddmax)
  77.             cout<<"Ngay tiep theo cua thang moi roi!!!";
  78.         }
  79.         {
  80.             cout<<"LOI" ;
  81.         }
  82.     }
  83.            
  84.         default:
  85.         {
  86.             cout<<"KHONG HOP LE";
  87.         }
  88.         }
  89.     }
  90.     getch();
  91.     return  0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement