小编Sce*_*T1c的帖子

用于计算项目的xp的python代码

我正在尝试将C++代码转换为python但我被卡住了

原始的C++代码

int main(void)
{
    int levels = 40;
    int xp_for_first_level = 1000;
    int xp_for_last_level = 1000000;

    double B = log((double)xp_for_last_level / xp_for_first_level) / (levels - 1);
    double A = (double)xp_for_first_level / (exp(B) - 1.0);

    for (int i = 1; i <= levels; i++)
    {
        int old_xp = round(A * exp(B * (i - 1)));
        int new_xp = round(A * exp(B * i));
        std::cout << i << " " << (new_xp - old_xp) << std::endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

python代码

import math …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

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

Javascript数组未定义大小

我正在尝试使用while循环填充数组.当我尝试读取某个索引处的数据时,它一直给我未定义但数组的长度告诉我必须添加一些东西.

  var test = [];
  while (i < 16)
  {
    test[i] = i;
    i++;
    console.log(test.length);
    console.log(test[i]);
  }
Run Code Online (Sandbox Code Playgroud)

控制台输出:

1
Fibbo.html:48 undefined
Fibbo.html:47 2
Fibbo.html:48 undefined
Fibbo.html:47 3
Fibbo.html:48 undefined
Fibbo.html:47 4
Fibbo.html:48 undefined
Fibbo.html:47 5
Fibbo.html:48 undefined
Fibbo.html:47 6
Fibbo.html:48 undefined
Fibbo.html:47 7
Fibbo.html:48 undefined
Fibbo.html:47 8
Fibbo.html:48 undefined
Fibbo.html:47 9
Fibbo.html:48 undefined
Fibbo.html:47 10
Fibbo.html:48 undefined
Fibbo.html:47 11
Fibbo.html:48 undefined
Fibbo.html:47 12
Fibbo.html:48 undefined
Fibbo.html:47 13
Fibbo.html:48 undefined
Fibbo.html:47 14
Fibbo.html:48 undefined
Fibbo.html:47 15
Fibbo.html:48 undefined
Fibbo.html:47 16
Fibbo.html:48 …
Run Code Online (Sandbox Code Playgroud)

javascript arrays

-6
推荐指数
1
解决办法
62
查看次数

标签 统计

arrays ×1

javascript ×1

python ×1

python-3.x ×1