这是我到目前为止所拥有的,但似乎每当我尝试运行它时,它就会关闭.
function wait(seconds)
local start = os.time()
repeat until os.time() > start + seconds
end
function random(chance)
if math.random() <= chance then
print ("yes")
elseif math.random() > chance then
print ("no")
end
random(0.5)
wait(5)
end
Run Code Online (Sandbox Code Playgroud)
这是完整的背景.
我在尝试编译时遇到标题错误.
#include <iostream>
using namespace std;
int chance()
{
return rand()%11;
}
int main()
{
if (chance > 5)
cout << "You win." << endl;
else
cout << "You lose." << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的完整代码,我试图让它输出你赢了或输了,50-50