2015-09-15 72 views
0

閱讀教程,但我無法弄清楚如何做到這一點。它希望讓我的程序顯示之前在quit子之後輸入的所有10個名稱。我已經嘗試過一些東西,但無法弄清楚如何做到這一點。在Liberty BASIC中顯示完整陣列

'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 

回答

0

插入此代碼[quit]end之間:

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

這會工作;)