根據題目,除以 0 就會變成 0
This commit is contained in:
@@ -74,6 +74,10 @@ class Calculator {
|
||||
tempFormula.append(number)
|
||||
}
|
||||
|
||||
if ["inf", "-inf", "nan"].firstIndex(of: tempFormula.last!) != nil {
|
||||
tempFormula = ["0"]
|
||||
}
|
||||
|
||||
return tempFormula.last!
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user