小编mar*_*rkh的帖子

Python在python中随机选择多个选项

我尝试做的是将问题1以不同的顺序随机化到问题20,当它是随机的时候我也可以在问题中输入我的答案.每当我尝试使用随机语句时,它总是会出现错误或意图错误.代码现在做的是按顺序打印问题.我所要做的就是将if和elif语句一起随机化

{} PY

name = raw_input("Hello what is your name? ")

print "Hi " + name

ready = raw_input("Are you ready to do the test?(Please enter YES/NO)")

while ready.lower() != "yes":
ready = raw_input("Are you ready to do the test?(Please enter YES/NO)")

if ready.lower() == "yes":
    print "Excelent! The test will start in any second. "
if ready.lower() == "no":
    print "Okay, tell me when you're ready. "
elif ready.lower() != "yes" and "no":
    print "It okay if your're not …
Run Code Online (Sandbox Code Playgroud)

python random

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

当c中的memset结构数组时出现分段错误

我试图清空struct数组中的所有数据.

但事实证明是分段错误.有人可以帮帮我吗.

结构

struct entry
{
   char  user;
    char  name[9];
    char  extension[4];
    short blockcount;
    short block[8];
};
struct entry directory[128];
Run Code Online (Sandbox Code Playgroud)

主要()

for (int i = 0; i < 128; ++i)
{
      memset(&directory[i], 0, sizeof(directory));
}
Run Code Online (Sandbox Code Playgroud)

c arrays struct for-loop memset

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

标签 统计

arrays ×1

c ×1

for-loop ×1

memset ×1

python ×1

random ×1

struct ×1