小编Cin*_*ere的帖子

试图在Lua中随机选择

这是我到目前为止所拥有的,但似乎每当我尝试运行它时,它就会关闭.

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)

这是完整的背景.

random lua function

2
推荐指数
1
解决办法
352
查看次数

错误:iso c ++禁止指针和整数之间的比较[c ++]

我在尝试编译时遇到标题错误.

#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

c++ pointers function codeblocks

0
推荐指数
1
解决办法
746
查看次数

标签 统计

function ×2

c++ ×1

codeblocks ×1

lua ×1

pointers ×1

random ×1