Turing String / Int(将它们放在同一行)

时间:2016-03-02 20:03:14

标签: arrays line turing

这是我目前的代码:

var compMark : array 1 .. 5 of real
var name : array 1 .. 5 of string
var counter : int := -1
for i : 1 .. 5
    counter := counter + 1
    exit when (counter = 5)
    put "What is your name?"
    get name (i)
    if name (i) = "stop" then
        cls
        exit
    end if
    put "What is your mark in Computer Science?"
    get compMark (i)
    if compMark (i) < 0 or compMark (i) > 100 then
        cls
        put "Error"
        return
    end if
    put ""
end for
cls
put "Name \t\t Computer Science mark"
for i : 1 .. upper (name)
    put name (i)
end for
for j : 1 .. upper (compMark)
    put "\t\t", compMark (j)
end for

这就是输出结果:

姓名计算机科学标记

名称

名称

名称

75

35

98

我希望输出如何:

姓名计算机科学标记

名称75

名称35

名称98

任何人都知道如何帮助我吗?

1 个答案:

答案 0 :(得分:0)

看起来像

for i : 1 .. upper (name)
    put name (i)
end for
for j : 1 .. upper (compMark)
    put "\t\t", compMark (j)
end for

应该是:

for i : 1 .. 5
    put name (i), "\t\t", compMark (i)
end for