Guest User

Untitled

a guest
Oct 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int isLeapYear(int year)
  4. {
  5. int result;
  6. if(year % 4 == 0)
  7. {
  8. if(year % 100 == 0)
  9. {
  10. if(year % 400 ==0)
  11. {
  12. result = 1;
  13. }
  14. else
  15. {
  16. result = 0;
  17. }
  18. }
  19. else
  20. {
  21. result = 1;
  22. }
  23. }
  24. else
  25. {
  26. result = 0;
  27. }
  28. return result;
  29. }
  30.  
  31.  
  32. int main()
  33. {
  34. int year = 2008;
  35. int days = 366;
  36.  
  37. while (days > 365)
  38. {
  39. if (isLeapYear(year))
  40. {
  41. if (days > 366)
  42. {
  43. days -= 366;
  44. year += 1;
  45. }
  46. }
  47. else
  48. {
  49. days -= 365;
  50. year += 1;
  51. }
  52. break;
  53. }
  54.  
  55. printf("end\n");
  56. printf("year : %d days : %d\n", year, days);
  57. return 0;
  58. }
Add Comment
Please, Sign In to add comment