qq_33936605 于 2017.09.04 23:05 提问

start（）函数，我注释掉它没有

bool MainWindow::start() //模型，即产生0到总人数的随机数，其中白岗的数是有规律的
{
//三连连值日模型中，3个白岗，6个夜岗,班长不占白岗
int zongshu = specialgeshu+commongeshu;
int rand;
int a=0;//3
int b=0;//6
int TT=T;
QTime time = QTime::currentTime(); //获取当前时间
qsrand((time.msec()+time.second()*100000));
jieguo jieguotemp;
while(TT)
{
int base=(T-TT)*zongshu;
for(int i=0;i {
while(a {
if(b0) break;
if(i!=commongeshu-1)
{
rand=i + qrand() % ((commongeshu-1) - i);
}
if(i==commongeshu-1) rand=i;
jieguotemp = Jieguo[rand+base];
Jieguo[rand+base]=Jieguo[i+base];
Jieguo[i+base]=jieguotemp;
common[jieguotemp.number].isok=1;
common[jieguotemp.number].finished++;
common[jieguotemp.number].Wfinished++;
a++;
i++;
}
if(i!=zongshu)
{
a=0;
}
while(b<=5 && i<zongshu)
{
if(i!=zongshu-1)
{
rand= i + qrand() % ((zongshu-1) - i);
}
if(i==zongshu-1) rand=i;
jieguotemp = Jieguo[rand+base];
common[jieguotemp.number].isok=1;
common[jieguotemp.number].finished++;
common[jieguotemp.number].Bfinished++;
Jieguo[rand+base]=Jieguo[i+base];
Jieguo[i+base]=jieguotemp;
b++;i++;
}
if(i!=zongshu)
{
b=0;
}
}
TT--;
refasle();
}
// savejieguo();
return 1;
}