Days interval

I got days interval from 9 to 17. Week started in 4 day (Thursday) I need to write a code which shows list of the days. For example

9- 5

10- 6

11- 7

12- 1

13- 2

14- 3

15- 4

16- 5

17- 6

Could you show me how to do it or at least give advance?
I'll give you some good advance Lieberten, reply in details what you are really trying to accomplish and I can try to help you out!
I got interval from 9 to 17. It menas I got 9, 10, 11, 12, 13, 14, 15, 16, 17

Then into cin I enter week day when interval starts. For example I enter 4. It means 4=thursday.
So Number 9 is Thursday, Number 10 is Friday, Number 11 is Saturday, Number 12 is Sunday and so on.

How does code should look like?

Sorry for my bad english.

The first thing to do is work out the math. Once you understand that, you can work on the code.

If I understand the problem right, you're given an interval of days of the month (like 9 to 17) and which day of the week is the first day (day 4 = Thursday). Your task is to print out the day of the month and the day of the week for day in the interval.

If I have the problem right, then you can solve it as follows. First, subtract the day of week (4) from the day of month (9) to get the day of the month that is Sunday. 9-4=5 so the 5th is Sunday.

Now for any day of the month, subtract 5 and divide by 7. The remainder will be the day of the week (0=Sunday, 1=Monday, ... 6=Saturday).

This is almost what you want, except it looks like you want to display the day of the week as 1-7 instead of 0-6. Once you figure the day using the formula above, just add 1 to compute the value to display.

I suggest you work a few of these out on pencil and paper. Once you have the hang of it, convert it to code. Have your code print out the intermediate values to help you get it working right. Once it's right, remove the code that prints intermediate values.
Thank you, dhayden! I did it. :)
Topic archived. No new replies allowed.