老程序员的两个问题

发布于 2024-09-19 03:42:31 字数 1432 浏览 6 评论 0原文

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

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

发布评论

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

评论(7

み格子的夏天 2024-09-26 03:43:23

QBasic 是我第一次接触编程。我当时九岁(四年级),我们有一台装有 MS-DOS 和 Windows 3.1 的 386DX。

我记得很有趣地修改 Nibbler 和 Gorillas 的代码,改变颜色和常量等。

因此,我制作的最有用、最复杂的程序是一个菜单驱动的应用程序,它询问用户数学问题:用户可以选择难度递增的数字级别,我记得硬编码了 100 个算术问题,检查用户的反应并告诉他们是否他们是否弄错了。

不确定我是否仍然有该代码,我想我可能会,今晚我会检查并发布如果我找到它!

...好吧!我找到了一些东西。该片段是名为“TEST1.BAS”的文件的一部分,看起来像上述程序的早期版本。我相信我有一个更完整的版本,但当我们的硬盘崩溃并且我们无法恢复所有文件时它就丢失了。

CLS
PRINT
PRINT "     menu"
PRINT "--------------"
PRINT "1. level 1"
PRINT "2. level 2"
PRINT "3. level 3"
PRINT "4. level 4"
PRINT "5. level 5"
PRINT "6. level 6"
PRINT "7. level 7"
PRINT "8. level 8"
PRINT "9. level 9"
PRINT "10. level 10"
PRINT "11. OTHER"
PRINT
INPUT "Your selection: ", choice%
PRINT

IF choice% = 1 THEN
CLS
DO
   INPUT "what is 4 + 4 ? ", num
LOOP UNTIL num = 8
PRINT
PRINT "correct"

DO
   INPUT "what is 8 - 6 ? ", num
LOOP UNTIL num = 2
PRINT
PRINT "correct"

DO
   INPUT "what is 8 + 7 ? ", num
LOOP UNTIL num = 15
PRINT
PRINT "correct"

DO
   INPUT "what is 9 - 4 ? ", num
LOOP UNTIL num = 5
PRINT
PRINT "correct"

DO
   INPUT "what is 6 + 5 ? ", num
LOOP UNTIL num = 11
PRINT
PRINT "correct"
END IF

IF choice% = 2 THEN
CLS
DO
   INPUT "what is 11 + 6 ? ", num
LOOP UNTIL num = 17
PRINT
PRINT "correct"

DO
   INPUT "what is 21 - 5 ? ", num
LOOP UNTIL num = 16
PRINT
PRINT "correct"

DO
   INPUT "what is 2 * 2 ? ", num
LOOP UNTIL num = 4
PRINT
PRINT "correct"

DO
   INPUT "what is 14 + 8 ? ", num
LOOP UNTIL num = 22
PRINT
PRINT "correct"

DO
   INPUT "what is 17 - 5 ? ", num
LOOP UNTIL num = 12
PRINT
PRINT "correct"

END IF

IF choice% = 3 THEN

END IF

IF choice% = 4 THEN

END IF

IF choice% = 5 THEN

END IF

IF choice% = 6 THEN

END IF

IF choice% = 7 THEN

END IF

IF choice% = 8 THEN

END IF

IF choice% = 9 THEN

END IF

IF choice% = 10 THEN

END IF

QBasic was my first experience with programming. I was nine-years old (fourth grade) and we had a 386DX with MS-DOS and Windows 3.1.

I remember having fun hacking the code for Nibbler and Gorillas changing colors and constants and such.

So the most useful and complex program I made was a menu driven application which quizzed the user on math problems: there were ascending numeric levels of difficulty the user could choose from and I remember literally hardcoding 100 arithmetic problems checking the users response and telling them whether they got it wrong or not.

Not sure if I still have that code laying around, I think I might, I'll check tonight and post if I find it!

...alright! I found some stuff. This snippet is part of a file named "TEST1.BAS" and looks like an early version of the program described above. I believe I had a more complete version but it was lost when our hard drive crashed and we weren't able to recover all files.

CLS
PRINT
PRINT "     menu"
PRINT "--------------"
PRINT "1. level 1"
PRINT "2. level 2"
PRINT "3. level 3"
PRINT "4. level 4"
PRINT "5. level 5"
PRINT "6. level 6"
PRINT "7. level 7"
PRINT "8. level 8"
PRINT "9. level 9"
PRINT "10. level 10"
PRINT "11. OTHER"
PRINT
INPUT "Your selection: ", choice%
PRINT

IF choice% = 1 THEN
CLS
DO
   INPUT "what is 4 + 4 ? ", num
LOOP UNTIL num = 8
PRINT
PRINT "correct"

DO
   INPUT "what is 8 - 6 ? ", num
LOOP UNTIL num = 2
PRINT
PRINT "correct"

DO
   INPUT "what is 8 + 7 ? ", num
LOOP UNTIL num = 15
PRINT
PRINT "correct"

DO
   INPUT "what is 9 - 4 ? ", num
LOOP UNTIL num = 5
PRINT
PRINT "correct"

DO
   INPUT "what is 6 + 5 ? ", num
LOOP UNTIL num = 11
PRINT
PRINT "correct"
END IF

IF choice% = 2 THEN
CLS
DO
   INPUT "what is 11 + 6 ? ", num
LOOP UNTIL num = 17
PRINT
PRINT "correct"

DO
   INPUT "what is 21 - 5 ? ", num
LOOP UNTIL num = 16
PRINT
PRINT "correct"

DO
   INPUT "what is 2 * 2 ? ", num
LOOP UNTIL num = 4
PRINT
PRINT "correct"

DO
   INPUT "what is 14 + 8 ? ", num
LOOP UNTIL num = 22
PRINT
PRINT "correct"

DO
   INPUT "what is 17 - 5 ? ", num
LOOP UNTIL num = 12
PRINT
PRINT "correct"

END IF

IF choice% = 3 THEN

END IF

IF choice% = 4 THEN

END IF

IF choice% = 5 THEN

END IF

IF choice% = 6 THEN

END IF

IF choice% = 7 THEN

END IF

IF choice% = 8 THEN

END IF

IF choice% = 9 THEN

END IF

IF choice% = 10 THEN

END IF
如果没有你 2024-09-26 03:43:17

a 和 b 的答案:一个程序,用户在其中输入吉他上的琴弦名称和音品编号,程序将输出该品品的音符。顺便说一句,我喜欢 qbasic,因为它的简单性使它变得有趣!

answer for both a and b: a program where the user would enter the string name and fret number on a guitar and the program would output which note the fret is. BTW, I love qbasic because its simplicity makes it fun!

总攻大人 2024-09-26 03:43:13

最有用,也可能是最复杂:我用 QBasic 编写了一个测验程序,它支持鼠标、可以单击的图形按钮等。它还使用通用文件格式,因此您可以编写新问题并在需要时加载它们。如果您有兴趣,该代码是在线的,但遗憾的是相关的图像/数据/等文件随着时间的推移而丢失了:
http://code.google.com/p/ justinethier/source/browse/trunk/qbasic_quizzer/project.bas

Most Useful, and probably most complex: I wrote a quizzer program in QBasic that had mouse support, graphical buttons you could click, etc. It also used a generic file format so you could write new questions and load them in if you wanted to. The code is online if you are interested, although sadly the associated image / data / etc files are lost to time:
http://code.google.com/p/justinethier/source/browse/trunk/qbasic_quizzer/project.bas

混吃等死 2024-09-26 03:43:06

我从来没有真正接触过 QBasic。
这是因为我不是一个老程序员。
我做过的大多数(适合A)B)
编写了一个从键盘读取数字的程序,
然后计算出其中的 10%,并将其打印到屏幕上。

这一定是在 2000 年,当时澳大利亚正在征收 10% 的商品及服务税。
这让我9岁了。
我记得我花了大约 6 个月的时间寻找一台装有 QBasic 的计算机。

美好的回忆,不那么,遥远的过去

I never really got so far with QBasic.
This would be because I'm not an old programmer.
Most I ever did, (fitting both A) and B) )
was make a program the read a number from keyboard,
and then calculated 10% of it, pringitng that to screen.

This must have been in 2000, as 10% gst was being introduced in australia.
That makes me 9 years old.
I remember spending like 6 months looking for a computer with QBasic on it.

Fond memories, of the, not so, distant past

请帮我爱他 2024-09-26 03:42:58

最复杂:霍夫曼编码器使用字符串来存储树。我不认为我能成功。

最有用:宫殿聊天迷宫编辑器/生成器。

Most complex: Huffman coder using a string to store the tree. I don't think i got it working.

Most useful: Palace chat maze editor/generator.

满天都是小星星 2024-09-26 03:42:54

虽然我从未使用过 QBasic(我设法跳过了拥有它的机器的一代),但我确实在其前身 GWBasic 中编写了 Z80 汇编器,以及某些硬件的支持代码,以将生成的机器代码传输到我的测试平台。它肯定是复杂的,而且非常混乱和缓慢,但那是因为我不太了解(当时没有学习任何数据结构和算法课程)。

Although I never used QBasic (I managed to skip the generation of machines that had it) I did write a Z80 assembler in its predecessor, GWBasic, together with support code for some hardware to transfer the resulting machine code to my test platform. It most certainly qualified as complex, as well as being very messy and slow, but that's because I didn't know better (having not taken any data structures and algorithms classes at that point).

捶死心动 2024-09-26 03:42:47

那些日子 GOTO 曾经是那么容易:-)

GOTO used to be so easy those days :-)

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