Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. The required interface is:
  2.  
  3. int CountFriday13 ( int y1, int m1, int d1,
  4. int y2, int m2, int d2,
  5. long long int * cnt )
  6. y1, m1, d1
  7. are input parameters representing year, month, and day. They define the start of the interval,
  8. y2, m2, d2
  9. are input parameters representing year, month, and day. They define the end of the interval,
  10. cnt
  11. is an output parameter. The function must fill it with the counted number of Friday 13 found in the input time interval. The parameter is to be set only if the input parameters are valid. If the input parameters are invalid, the function must not modify the output parameter in any way. The counted Fridays 13 shall include potential Fridays 13 in both start and end day of the interval.
  12. return value
  13. must be set to 1 if the input was valid, 0 if the input parameters were invalid.
  14. The input parameters must define a valid date. To be valid, the input must satisfy the following restrictions:
  15.  
  16. year must be greater or equal to 1900,
  17. month is valid (1 to 12),
  18. day is valid (1 to the number of days in the month),
  19. the end timestamp must not precede the start timestamp.
  20. Submit a source file with the implementation of the required function CountFriday13. Further, the source file must include your auxiliary functions which are called from CountFriday13. The function will be called from the testing environment, thus, it is important to adhere to the required interface. Use the sample code below as a basis for your development, complete CountFriday13 and add your required auxiliary functions. There is an example main with some test in the sample below. These values will be used in the basic test. Please note the header files as well as main is nested in a conditional compile block (#ifdef/#endif). Please keep these conditional compile block in place. They are present to simplify the development. When compiling on your computer, the headers and main will be present as usual. On the other hand, the header and main will "disappear" when compiled by Progtest. Thus, your testing main will not interfere with the testing environment's main.
  21.  
  22. We assume standard Gregorian calendar when counting days. Thus, there is a fixed number of days (30/31) in a month, with the exception of February. February is either 28 days (non-leap year) or 29 days (a leap year). The leap year rules of Gregorian calendar are:
  23.  
  24. years are not leap years in general,
  25. except multiples of 4 which are leap years,
  26. except multiples of 100 which are not leap years,
  27. except multiples of 400 which are leap years,
  28. except multiples of 4000 which are not leap years.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement