{
if(groups[i].time[k][l] == false)
{
for(int v = 0; v < numteachers; v++)
{
for(int w = 0; w < teachers[v].type_num; w++)
{ if((teachers[v].time[k][l] == false)&&(teachers[v].type[w] == groups[i].type[j]))
{
teach = v;
qDebug() << teachers[v].time[k][l];
qDebug() << teachers[v].type[w];
qDebug() << groups[i].type[j];
break;
}
qDebug() << teachers[v].time[k][l];
qDebug() << teachers[v].type[w];
qDebug() << groups[i].type[j];
}
if(teach != -1)
{
break;
}
}
if(teach == -1)
{
continue;
}
for(int v = 0; v < numclassrooms; v++)
{
for(int w = 0; w < classrooms[v].type_num; w++)
{if((classrooms[v].time[k][l] == false)&&(classrooms[v].type[w] == find_subject(groups[i].type[j])))
{
aud = v;
break;
}
}
if(aud != -1)
{
break;
}
}
if(aud == -1)
{
continue;
}
groups[i].time[k][l] = true;
teachers[teach].time[k][l] = true;
classrooms[aud].time[k][l] = true;
groups[i].scedule_classroom[k][l] = aud;
groups[i].scedule_subj[k][l] = find_subj_id(groups[i].type[j]);
groups[i].scedule_teacher[k][l] = teach;
groups[i].task[j]--;
set = true;
qDebug() << "[" << k << "][" << l << "]\t" << groups[i].name << "\t" << groups[i].type[j] << "\t" << teachers[teach].name << "\t" << classrooms[aud].name;
if(groups[i].task[j] != 0)
{
j--;
}
break;
}
}
if(set)
{ break; } } } } }}
QString CEngine::find_subject(QString name)
{
for(int i = 0; i < this->numsubjects; i++)
{
if(this->subjects[i].name == name)
{
return this->subjects[i].type[0];
}
}
return "";
}
int CEngine::find_subj_id(QString name)
{
for(int i = 0; i < this->numsubjects; i++)
{
if(this->subjects[i].name == name)
{
return i;
}
}
return -1;
}
void CEngine::write_debug(int id)
{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 6; j++)
{
QString txt[4];
txt[0] = groups[id].name;
if(groups[id].scedule_classroom[i][j] == -1)
{
txt[1] = "--";
}
else
{
txt[1] = classrooms[groups[id].scedule_classroom[i][j]].name;
}
if(groups[id].scedule_subj[i][j] == -1)
{
txt[2] = "--";
}
else
{
txt[2] = subjects[groups[id].scedule_subj[i][j]].name;
}
if(groups[id].scedule_teacher[i][j] == -1 )
{
txt[3] = "--";
}
else
{
txt[3] = teachers[groups[id].scedule_teacher[i][j]].name;
}
qDebug() << "[" << i << "][" << j << "]\t" << txt[0] << "\t" << txt[1] << "\t" << txt[2] << "\t" << txt[3];
} }}
int CEngine::Get_numgroups()
{
return this->numgroups;
}