学习qbasic并试图理解我刚写的代码

学习qbasic并试图理解我刚写的代码

本文介绍了学习qbasic并试图理解我刚写的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我遇到了一个问题,告诉我用星星打印一个三角形。



我最终猜测并检查并取出它。

So I had a problem on a hw assignment that told me to print a triangle out of stars.

I ended up guessing and checking and pulling out this.

DIM LINES AS INTEGER
CLS

INPUT "How many lines will your triangle be: ", LINES

FOR x = 1 TO LINES
    PRINT
    FOR y = 1 TO x
        PRINT "*";
    NEXT y
NEXT x
END





守则有效,但我不明白怎么做。我已经快速掌握了编程,但嵌套循环让我在大部分时间都感到困惑。我现在很难学习qbasic,但这就是我的学校提供​​的。有人可以解释我刚才写的代码。并帮助我DO和FOR命令。谢谢我,我的硬件非常好,所以我的老师没有帮助。



我尝试了什么:



我猜并检查了代码,现在我很困惑。我只是要求解释。尝试自我解释,但是,没有理解它。



The Code works but I dont understand how. I've picked up programming fast, but nested loops have left me confused most of the time. I now its weird to be learning qbasic but that is what my school offers. Can someone please explain the code I just wrote. And help me with DO, and FOR commands. Thank You I am really far ahead with the HW so my teacher isnt helping.

What I have tried:

I guess and checked the code and am now confused. An explanation is all im asking for. Tried to self explain but, didnt understand it.

推荐答案

NEXT Y
NEXT X





我会做类似的事情





I would have done something like

NEXT Y
PRINT (something to make a new line)
NEXT X





但是自从我做了任何BASIC以来已经很长时间了,所以你必须要看一下



有帮助吗?









如果你缩进,它也更容易看到'循环' em $ / $




but its been a long time since Ive done any BASIC so you'll have to look that up

does that help ?




Its also easier to see 'loops' if you indent them

FOR X = 1 to LINES
    FOR Y = 1 to X

    NEXT Y
NEXT X





[/ EDIT]



[/EDIT]



这篇关于学习qbasic并试图理解我刚写的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 00:45