fun main(args: Array<String>) {
var sum: Int = 0
var input: String
do {
print("Enter an integer: ")
input = readLine()!!
sum += input.toInt()
} while (input != "0")
println("sum = $sum")
}
輸出畫面
Enter an integer: 12
Enter an integer: 23
Enter an integer: 23
Enter an integer: 344
Enter an integer: 0
sum = 402
沒有留言:
張貼留言