// direction generator
static const char alpha[] = "DLP";
int d;
char genRandom()
{
return alpha[rand() % d +1];
}
// end of generator
while(true)
{
cout << genRandom();
}
它应该生成d
字符。例如:根据输入号码生成字符
输入d:随机生成的
7
输出:
PDLDPLP
并即时得到无限数量的字符串,程序犯规止步于7它源源不绝,永远。
你什么时候灌输的值'D'? –