一个能直接显示你空闲日期的日历

huangapple go评论64阅读模式
英文:

A calendar that says directly your free days

问题

以下是翻译好的内容:

我可以给一些建议,关于如何创建一个可以显示用户空闲日期的日历吗?

我会更详细地解释一下:我想创建一个程序(最好使用C++或Java,因为我们在学校学习这些语言),它可以读取(可能是从txt文件或其他文件中读取)我已经安排了事务的日期,并将这些日期排除,然后得到其他日期的输出。

示例:

我的txt文件包含:

13, 14, 20, 21, 25, 11, 3, 30

程序的预期输出:

1, 2, 4, 5, 6, 7, 8, 9, 10, 12, 15, 16, 17, 18, 19, 22, 23, 24, 26, 27, 28, 29, 31

对于这个可能有些愚蠢的问题,我是新手,但我想学习。非常感谢任何建议,如果有什么不清楚的地方,请告诉我!

英文:

can I have some suggestions on how to create a calendar that says the free days of the user?

I will explain it better: I'd like to create a program (possibly in C++ or Java since we are learning that at school) that reads (maybe in a txt file or something) the days where I am busy and exclude them and then get the output of the other days.

Example:

My txt file contains:

13, 14, 20, 21, 25, 11, 3, 30

Expected output from the program

1,2,4,5,6,7,8,9,10,12,15,16,17,18,19,22,23,24,26,27,28,29,31

Sorry for the stupid question but I'm new to programming and would like to learn, thanks for any advice, and if something is unclear please let me know!

答案1

得分: 2

语言无关*解决方案:

  1. 创建一个包含31个布尔值的数组。

  2. 使用文本文件中的数字,将这些索引处的值标记为true

  3. 遍历该数组,并打印那些值为false的索引。

如有必要,根据编程语言和数组定义,调整逻辑以处理以零为基的数组索引。

**) 适用支持数组的编程语言。

英文:

Language-agnostic<sup>*<sup> solution:

  1. Create an array of 31 booleans.

  2. Using the numbers in the text file, mark the values at those indexes as true.

  3. Iterate the array and print the indexes of the ones that are false.

If needed, depending on language and array definition, adjust logic to handle array indexes being zero-based.

<sup>*) For programming languages that support arrays.<sup>

答案2

得分: 0

在这个答案中,我将专注于“我是编程新手,想学习,请给予任何建议”。

无论何时你想学习,都必须去实践。无论多么多的谈论、阅读和倾听都无法取代你想学习的实际操作。因此,如果你真的想学习,思考你的问题,用语言表达出一个可能的答案(你可以在集成开发环境中编写待办注释来记录你构想的步骤),然后尝试去实现它。你会遇到困难。停下来,思考为什么某些事情不如你所愿地工作,并进行相应的更改。允许自己犯错。犯错(并理解这些错误!)是学习时你能做的最好的事情。

你可能会在某个点上陷入困境,所有你能想到的方法都失败了。这时候是寻求帮助的合适时机,提供关于你已经完成了哪些方面、你到目前为止尝试了什么以及你需要什么继续的信息。

所以针对你的问题:选择一门语言并开始。当你真正陷入困境时,就针对你的问题提一个具体的问题。不要只是寻求解决方案。

英文:

In this answer I will focus on "I'm new to programming and would like to learn, thanks for any advice".

Whenever you want to learn, you have to DO. no amount of talking, reading and listening can replace doing the thing you want to learn. So if you really want to learn, think about your problem, verbalize a possible answer (you can write the steps you make up in to-do-comments in your IDE) and try to implement it. You will get stuck. Take a breath and think about why something is not working as you want it to and change it accordingly. Allow yourself to make mistakes. Making mistakes (and understanding them!) is the best thing you can do when learning.

You might get stuck at a point where all you can think of fails. Then is the right time to ask for help, providing information on what you already have, on what you tried so far and what you need to continue.

So for your problem: choose one language and start. When you really get stuck, ask a specific question about your problem. Don't just ask for a solution.

huangapple
  • 本文由 发表于 2020年10月17日 14:01:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/64399463.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定