gpt4 book ai didi

ios - 我不知道如何让它们加减,这是有办法的。基本上我想要 1"+"3 = 4 但我得到 1+3

转载 作者:行者123 更新时间:2023-11-28 10:57:47 25 4
gpt4 key购买 nike

<分区>

let randsign = Int(arc4random_uniform(2) + 1)

//This function returns a random operator
func whatSign(par1:Int)-> String {

if (par1 == 1){
return "+"

}
else {
return "-"
}

}

var sigh = whatSign(par1: randsign)

let randnum1:Any = Int (arc4random_uniform(10) + 1)
let randnum2:Int = Int (arc4random_uniform(10) + 1)

//我想让变量“finVal”进行数学运算,但没有,因为变量“sign”是字符串

let finVal = "\(randnum1)\(sigh)\(randnum2)"
print(finVal)

//When I print I get for example 1-3, 9-4, 8+2 .But I wanted them to do arithmetic

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com