Guest User

Untitled

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