【问题标题】:Displaying full array in Liberty BASIC在 Liberty BASIC 中显示完整数组
【发布时间】:2015-09-15 13:09:34
【问题描述】:

通过教程,但我不知道如何做到这一点。它希望我让程序显示之前在 quit 子之后输入的所有 10 个名称。我已经尝试了一些东西,但无法弄清楚如何做到这一点。

'ARRAYS.BAS
    'List handling with arrays
    dim names$(10)  'set up our array to contain 10 items

[askForName]  'ask for a name
    input "Please give me your name ?"; yourName$
    if yourName$ = "" then print "No name entered." : goto [quit]

    index = 0
[insertLoop]
    'check to see if index points to an unused item in the array
    if names$(index) = "" then names$(index) = yourName$ : goto [nameAdded]
    index = index + 1 'add 1 to index
    if index < 10 then [insertLoop] 'loop back until we have counted to 10

    'There weren't any available slots, inform user
    print "All ten name slots already used!"
    goto [quit]

[nameAdded]  'Notify the name add was successful
    print yourName$; " has been added to the list."
    goto [askForName]

[quit]
    end

【问题讨论】:

    标签: arrays basic


    【解决方案1】:

    [quit]end 之间插入此代码:

    for I = 0 TO 10
    print names$(I)
    next I
    

    这行得通;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-31
      • 2019-10-13
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多