不是本课的问题,自己实践遇到的问题
var enemyLives = Int()
var damage = Int()
enemyLives = 15
damage = 3
var attackTimesVerify = enemyLives % damage
var attackTimes = enemyLives / damage
if attackTimesVerify == 0 {
println("\(attackTimes) attacks needed!")
} else {
attackTimes = attackTimes + 1
println("\(attackTimes) attacks needed!")
}
for var i = 1 ;i <= 5; i++ {
for enemyLives; enemyLives >= 0; enemyLives -= damage {
if enemyLives > 0 {
println("round" + "\(i)" + ": " + "\(enemyLives)hp left!")
} else {
println("you win")
}
}
}
控制台输出全部是“round1”,
怎么变成有序的“round1”“round2”“round3”…… ?