def jose_prob(n, m): if n < 1: return "Parameter Error." if m < 1: return "Parameter Error." if m <= n : return "Parameter Error." if isinstance(m, float) or isinstance(n, float): return "Parameter Error." flag = 9 jose_list = [1 for i in range(0, n)] # 1 live ;0 dead start = 0 for i in range(0, n - m): j = 0 k = 0 while j < flag: if jose_list[(start + k) % n] != 0: # not dead j += 1 k += 1 dead = (start + k - 1) % n jose_list[dead] = 0 start = dead + 1 return jose_list
时间: 2023-06-06 17:05:48 浏览: 44
这是一个名为jose_prob的函数,输入n和m两个参数。如果n小于1,则返回“参数错误”。如果m小于1,则返回“参数错误”。如果m小于等于n,则返回“参数错误”。如果m或n是浮点数,则返回“参数错误”。如果以上条件都满足,则创建一个长度为n的列表,并给每个元素赋值为1,然后返回这个列表。
相关问题
jose.JWKRSA.key.generate 报错AttributeError: 'member_descriptor' object has no attribute 'generate'
这个错误可能是因为您使用了错误的对象或方法。在使用 jose 库中的 JWKRSA 生成密钥对时,您应该按照以下步骤进行操作:
1. 导入 JWKRSA:
```
from jose import jwk
```
2. 使用 JWKRSA.generate_key() 方法生成密钥对:
```
key = jwk.JWKRSA.generate_key(kty='RSA', size=2048)
```
在这个例子中,我们指定了密钥类型为 RSA,密钥长度为 2048 bits。您可以根据自己的需要调整这些参数。
请注意,如果您使用的是 Python 2.x 版本,您可能需要在 import 语句中添加括号,即:
```
from jose import jwk()
```
希望这可以帮助您解决问题。
test.c: In function ‘Josegh’: test.c:43:9: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration] free (temp); ^ test.c:43:9: warning: incompatible implicit declaration of built-in function ‘free’ test.c:43:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’ test.c:50:5: warning: incompatible implicit declaration of built-in function ‘free’ free(h); ^ test.c:50:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’ test.c: In function ‘WriteDat’: test.c:6:27: warning: implicit declaration of function ‘fopen_s’ [-Wimplicit-function-declaration] #define FOPEN(fp, f, flg) fopen_s(&fp, f, flg) ^ test.c:67:2: note: in expansion of macro ‘FOPEN’ FOPEN(fp, "jose.out", "w"); ^ /tmp/ccGNfI3m.o:在函数‘Josegh’中: test.c:(.text+0xe):对‘looplistcreat’未定义的引用 test.c:(.text+0x2c):对‘loopin’未定义的引用 test.c:(.text+0x42):对‘loopcut’未定义的引用 /tmp/ccGNfI3m.o:在函数‘WriteDat’中: test.c:(.text+0x15f):对‘fopen_s’未定义的引用 collect2: error: ld returned 1 exit status
这是一段C语言代码的编译错误和警告信息。其中包括以下问题:
1. 在函数Josegh中,使用了未定义的函数looplistcreat、loopin和loopcut,这可能是因为没有包含相应的头文件或者没有正确实现这些函数。
2. 在函数Josegh中,使用了函数free,但是编译器提示没有提供free函数的声明。需要包含头文件stdlib.h来解决这个问题。
3. 在函数WriteDat中,使用了函数fopen_s,但是编译器提示没有提供fopen_s函数的声明。可能是因为没有包含相应的头文件或者没有正确实现这个函数。
4. 在编译链接时,出现了ld returned 1 exit status的错误,这通常是因为缺少某些库文件或者链接时出现了错误。
为了解决这些问题,可以尝试按照编译器提示的建议进行修改,例如添加头文件、提供函数声明或者实现相应的函数。