Creating a program that will tell a user what month it will be x months from now ( C++) [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am completely stuck / lost. I need to write a program that will tell a user what month it will be in x amount of months from March. I need a point in the right direction to start me off.
I am still learning c++, so I'm trying to keep it as basic as possible. Any help will be a lifesaver !!
Example:
User enters 6, the result would display September.
User enters 239, the result would be February.

Just get the input % 12 and add it to March . For example in case of 239 :
239 % 12 = 11 ---> 11 months after march is february.
Logic : there are 12 months in an year. So march will again come in a cycle of 12.
Now so n/12 years will pass as it is. So after n/12 years you will be again at march. After that only n%12 months remain. So you can add them up directly to get your answer.

Related

Regex: Is the input date within the next two weeks? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 days ago.
Improve this question
The input is a person's date of birth (e.g. 22/Feb/78).
Using a regular expression, I want to find out if the person has their birthday within the next two weeks from now.
So I want to know if February 22nd (the year needs to be ignored, of course) is within the next 14 days from now. Today is February 13th, so the correct result would be: yes.
Is there a way to do this?
I tried ChatGPT but it was not available for me due to capacity reasons.
So I tried https://www.autoregex.xyz/ and entered "Is the date (mm.dd.) within the next two weeks?".
Result:
\d{2}\.\d{2}\.\s*(?:[0-9]|1[0-9]|2[0-9]|3[0-1])\s*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*(?:19|20)\d{2}
But it did not work.

How to find which word contained within sentence [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a list of suppliers in a column (column A) in Google Sheets, and I have transactions list from my bank. Each item description (column B) in bank transactions list is a mess of the supplier name and numbers. For each item description I want to find a matching supplier name from the suppliers list. How can I do this?
try:
=ARRAYFORMULA(IFNA(REGEXEXTRACT(LOWER(B2:B),
LOWER(TEXTJOIN("|", 1, SORT(A2:A, 1, 1))))))

Getting Bitcoin's block number in a specific date and hour? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I would like to know what is the Bitcoin block number in an existing date at an exact hour. for example what is the block number closest to 1.1.2017 at 00:00 UTC. What is the easiest way to do so?
Convert the time to seconds since the UNIX epoch:
$ date -ud "1/1/2017"
Sun Jan 1 00:00:00 UTC 2017
$ date -ud "1/1/2017" +%s
1483228800
You can also use Epoch Converter to convert it.
Add three zeroes to that number and append it to a blockchain.com URL:
https://www.blockchain.com/btc/blocks/1483228800000
And there you have it:
446033 (Main Chain) 2017-01-01 00:02:33
And if you want the previous block, clock on the previous button and scroll to the end:
446032 (Main Chain) 2016-12-31 23:44:04
So block 446,032 was mined at 12/31/2016 at 23:44:04 UTC and block 446,033 was mined at two minutes and 33 seconds after midnight.

Hash Table ( Data Structure ) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Use the following data when building tables.
32, 64, 8, 23, 60, 47, 62, 59, 15, 29
Ans:
32-2
64-4
8-8
23-8
60-0
47-2
62-2
59-14
15-0
29-14
I understand the answers up to 23 because I can figure out how the answer is 8. My question is, how is 23%10 = 8? This also goes for the answers of 47, 59, and 29.
If it is even, calculate % 10
If it is odd, calculate % 15
This is the pattern that you should follow. Next time clarify and explain clearly to get better responses.

Choosing random event with different probabilities [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need help creating a general function or pseudocode that chooses a single event from a group events who all have different probabilities.
Ex.
event 1 = 45%
event 2 = 15%
event 3 = 50%
event 4 = 35%
event 5 = 50%
The simplest solution would be to sum and normalize the ranges (as an example, the sum of the values is 195, your first event would get the range [0, 45/195=0.23[, the second one [0.23, 0.23+0.076=0.31], and so on), then extract a number from [0,1[ and look to what range it belongs.