教孩子帕斯卡的简单问题

发布于 2024-07-22 07:07:07 字数 179 浏览 12 评论 0原文

我被要求辅导一个孩子的帕斯卡。 尽管我之前从未见过 Pascal,但我还是设法获得了教程,现在我已经知道足够的知识来教他了。

我写信给你们是为了看看是否有人可以给我指出一些涉及简单算法的基本练习,比如:对这个数组进行排序,求平均值等......

它可以是任何语言,我只需要找到一些练习这样他就可以锻炼了。

I've been asked to tutor Pascal to a kid. Despite never seen Pascal before I did manage to get a tutorial and I now know enough to teach him.

I am writing you guys to see if anyone can point me out some basic exercises that involve simple algorithms, Something like: Sort this array, find the average, etc...

It can be in any language, I just need to find some exercises so he can work out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

演出会有结束 2024-07-29 07:07:07

以下是学习新编程语言的 15 个练习的列表自由职业者扩展了多种语言中使用的基本技术,可以让他感受到他正在学习的新语言

Here is a list of 15 Exercises for Learning a new Programming Language from freelance that expands on basic techniques used in many languages and can give him a feel of the new lanaguage he's learning

梦幻的味道 2024-07-29 07:07:07

我将以(大部分)与语言无关的方式来解决这个问题。 在教他打印语句和流程控制(if 语句、for 循环等)之后,我的建议是从可以生成的简单 ASCII 艺术模式开始通过 for 循环等。

例如,如何打印半棵树,就像这样?

*
**
***
****
*****
******

好吧,现在你如何打印一棵完整树,就像这样?

     *
    ***
   *****
  *******
 *********
***********

现在尝试画一艘火箭飞船。 ;)

这些对于大多数孩子来说都很棒,因为它们是视觉化的,结果很诱人,并且练习将传授循环和消除冗余的重要性。

I am going to address this in a (mostly) language-agnostic fashion. After teaching him print statements and flow control (if statements, for loops, etc.), my suggestion would be to start off with simple ASCII-art patterns that can be generated by for loops and such.

For example, how would you print half of a tree, like this?

*
**
***
****
*****
******

Alright, now how would you print a full tree, like this?

     *
    ***
   *****
  *******
 *********
***********

Now try drawing a rocket ship. ;)

These are great for most kids because they are visual, the results are enticing, and the exercises will impart the importance of loops and eliminating redundancy.

如梦亦如幻 2024-07-29 07:07:07

有关排序算法请参阅链接。 这是一篇维基百科文章 - 有关排序算法的一些一般信息,但在下面您可以单独找到每种类型的链接,以及伪代码(和某些语言)的算法。

就“求平均值”而言,当您有“n”个元素时:

SUM=0.
DO i=1,n
 SUM=SUM+element(i)
ENDDO
AVRG=SUM/n

另外,出于学习目的和思考Project Euler 非常好。


另外,请看一下这个问题:
在哪里可以找到有趣/教育性的编程挑战?我没有想要复制粘贴所有内容,但它有一堆链接,其中包含您正在寻找的内容(编程练习)。 这是:算法问题网站您的编程练习是什么?。 您可能会在那里找到您认为他会感兴趣的东西。

For sorting algorithms see link. It is a Wikipedia article - a little general information on sorting algorithms, but down below you have links to every type of them individually, and algorithms in pseudo code (and some languages).

As far as "find the average" goes, when you've got "n" elements:

SUM=0.
DO i=1,n
 SUM=SUM+element(i)
ENDDO
AVRG=SUM/n

Also, for learning purposes and thinking Project Euler is very nice.


Also, do take a look at this question:
Where can you find fun/educational programming challenges? I didn't want to copy paste everything, but it has a bunch of links with stuff for exactly what you're looking for (programming exercices). And this: Algorithm Questions Website, What are your programming exercises?. You'll probably find something you think he'll be interested in in there.

醉生梦死 2024-07-29 07:07:07

经典一:
让程序选择一个随机数,游戏的目的是通过消除找到这个数字。 如果用户猜测的数字较小,则程序表示该数字太低;如果用户猜测的数字较高,则表示该数字太高。

classic one:
Let the program choose a random number, the purpose of the game is to find the number through elimination. if the user guesses a lower number the program says its too low, if its higher it says its too high.

如果没有你 2024-07-29 07:07:07

带有“AI”(即预定义动作)和文本图形的井字游戏是一个不错的项目。

Tic tac toe game with "AI" (that is predefined moves) and text-graphics is a nice project.

昔梦 2024-07-29 07:07:07

给它添加一些乐趣。 一个不错的开始:

剪刀布游戏

用户输入 P、R 或 S

程序会响应您获胜、失败或平局

更高级的功能:跟踪记录、获胜百分比、连胜/连败

Add some fun to it. A good one to start with:

Paper-Rock-Scissor Game

User enters P, R, or S

Program responds that you win, lose, or tie

More advanced features: track record, winning %, win/loss streak

长发绾君心 2024-07-29 07:07:07

对双向链表进行基本操作也是经典。

Doing basic operations on a doubly linked list is also a classic.

梦在深巷 2024-07-29 07:07:07

如果您了解任何类似 C/C 的语言,其基本相同:

  • { } 是 begin end;
  • == is ==
  • is :=
  • 不返回任何内容的函数是过程。
  • 返回某些内容的函数仍然是一个函数。
  • int 是整数。

其余的几乎是一样的。 语法有点不同,但差别不大。

您需要知道他们正在使用哪种 Pascal,以及他们教给他们什么,以确保您不会浪费您/他/她的时间。

If you know any C/C-like language it's basically the same:

  • { } are begin end;
  • == is =
  • = is :=
  • a function that returns nothing is a procedure.
  • a function that returns something is still a function.
  • int is Integer.

The rest is almost the same. The syntax is a bit different, but not very different.

You would need to know which Pascal they're using, and what they taught them to be sure you're not wasting your/his/her time.

烂柯人 2024-07-29 07:07:07

我学到的早期练习包括绘制Mandelbrot集 (现在计算机速度快得多,因此您不必立即担心优化)并实现像 生命游戏

当然,如果这是学校课程的练习,那么只有当测试可能测试类似的知识/技能领域时,这样的练习才会有帮助。

Early exercises I learned from include drawing the Mandelbrot set (computers are much faster these days so you don't immediately have to worry so much about optimization) and implementing cellular automata like the Game of Life.

Of course, if this is practice for a school course, exercises like this will only be helpful if the test is likely to test a similar domain of knowledge/skills.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文