Advertisement
nguyenhappy92

Xuất Ngày Tiếp Theo

Nov 24th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // Xuat ngay tiep theo
  2. // Khai bao cac ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5. int kt(int y)
  6. {
  7. if(y%400==0 ||(y%4==0&&y%100!=0))
  8. return 1;
  9. return 0;
  10. }
  11. // kiem tra ngay thang hop le
  12. int hople(int d,int m,int y)
  13. {
  14. if((d>0&&d<32)&&(m>0&&m<13)&&(y>0))
  15. return 1;
  16. return 0;
  17. }
  18. void main()
  19. {
  20. int d,m,y;
  21. scanf("%d%d%d",&d,&m,&y);
  22. if(hople(d,m,y)==1)
  23. {
  24. switch(m)
  25. {
  26. case 2:
  27. if(kt(y)==1)
  28. {
  29. if(d==29)
  30. {
  31. printf("1");
  32. }
  33. else
  34. {
  35. printf("%d",d+1);
  36. }
  37. }
  38. else
  39. {
  40. if(d==28)
  41. {
  42. printf("1");
  43. }
  44. else
  45. {
  46. printf("%d",d+1);
  47. }
  48. }break;
  49. case 1: case 3:case 5: case 7:case 8: case 10:case 12:
  50. if(d==31)
  51. {
  52. printf("1");
  53. }
  54. else
  55. {
  56. printf("%d",d+1);
  57. }
  58. break;
  59. default: if(d==30)
  60. {
  61. printf("1");
  62.  
  63. }
  64. else
  65. {
  66. printf("%d",d+1);
  67. }break;
  68. }
  69. }
  70. else
  71. {
  72. printf("0");
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement