Guest User

Untitled

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