我正在尝试编写一个递归函数来在python中打印某种排列.但是出于某种原因我得到了最大深度误差.
def perm(chars, k, word):
if k == 0:
print(word)
for char in chars:
perm(chars, k - 1, char + word)
perm(['1','2'], 2, '')
Run Code Online (Sandbox Code Playgroud)
任何人都知道错误是什么?
double fun(int i)
{
volatile double d[1] = {3.14};
volatile long int a[2];
a[i] = 1073741824;
return d[0];
}
Run Code Online (Sandbox Code Playgroud)
有趣(0)➙3.14
有趣的(1)➙3.14
有趣的(2)➙3.1399998664856
有趣的(3)➙2.00000061035156
好玩(4)➙3.14,然后分段错误
谁可以向我解释在这个例子中发生了什么以及为什么在调用func(2)时段错不会出现?为什么返回值不总是3.14?