根據題目,除以 0 就會變成 0

This commit is contained in:
2020-05-06 09:48:13 +08:00
parent 6fff73b8b6
commit 87406ad552

View File

@@ -74,6 +74,10 @@ class Calculator {
tempFormula.append(number)
}
if ["inf", "-inf", "nan"].firstIndex(of: tempFormula.last!) != nil {
tempFormula = ["0"]
}
return tempFormula.last!
}
}