我只是C++的新手。我可以帮助我随机化这些问题吗?有没有办法随机化这个?如何洗牌阵列问题?
我有这段代码。有人能告诉我如何随机化这些吗?
string questionpart[20]={"What is the square root of 4?",
"What is the square root of 6?",
"What is the square root of 16?",
"What is the square root of 25?",
"What is the square root of 36?",
"What is the square root of 42?",
"What is the square root of 48?",
"What is the square root of 81?",
"What is the square root of 100?",
"What is the square root of 121?",
"What is the square root of 144?",
"What is the square root of 169?",
"What is the square root of 196?",
"What is the square root of 225?",
"What is the square root of 256?",
"What is the square root of 289?",
"What is the square root of 324?",
"What is the square root of 361?",
"What is the square root of 400?",
"What is the square root of 1?",
};
string partans[20]={"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"1"};
感谢提前!
创建一个索引数组(0-19)并使用rand函数对其值进行洗牌。然后回答和问题不会丢失链接 – nikniknik2016
您应该使用计算器并仔细检查您的问题和答案。 – molbdnilo
您可以使用[std :: shuffle](http://www.cplusplus.com/reference/algorithm/shuffle/)。另外,你似乎在第二行中有错误印记。必须是“9的平方根”而不是“6的平方根”。而42和48也有同样的问题(必须是49和64)。 – Ilya