타임 스탬프, 현재 층 및 대상 층별로 요청을 읽는 기능이 있으며 예상 한대로 출력되지 않습니다.Bool : 0 또는 1이 아닌 cout의 잘못된 출력
bool을 제외하고 타임 스탬프, 현재 층 및 대상 층 모두 내 구성원 값이 올바르게 출력됩니다.
부울은 내 방향으로 대신 1 또는 0을 출력합니다.
노드 번호 : 타임 스탬프
Elevator::readRequests()
{
ifstream myStream("T1.txt");
while(!myStream.eof())
{
int timestamp ,currentFloor, destinationFloor;
myStream >> timestamp >> currentFloor >> destinationFloor;
//cout<< endl <<"The current timestamp is "<< timestamp << "The current floor is " << currentFloor
// << " and the destination floor is " << destinationFloor << endl << endl;
//cout<< endl;
reqNode *temp = new reqNode;
//initialize request node object
temp->timestamp = timestamp;
temp->start = currentFloor;
temp->destination = destinationFloor;
temp->start_time = -1;
temp->finish_time = -1;
temp->calculate_priority();
if(temp->start < temp->destination)
temp->set_dir(true);
else
temp->set_dir(false);
request.push(*temp);//push nodes into the request bank
}
int i = 0;
while(!request.empty())
{
cout << "Node " << i << " : " << request.front().timestamp << " " << request.front().start << " " << request.front().destination
<< " " << request.front().direction << endl;
request.pop();//popping the request in order to test
i++;
}
}
나는 출력을 얻기 위해 노력하고 있어요. 현재 (사용자 층). 대상 (사용자 층). 방향 (사용자가 진행중)
Node 0 : 1 3 7 1
Node 1 : 1 2 9 1
Node 2 : 1 7 9 1
Node 3 : 2 4 6 1
Node 4 : 2 4 8 1
Node 5 : 2 1 17 1
Node 6 : 5 1 15 1
Node 7 : 5 5 1 0
Node 8 : 6 17 4 0
Node 9 : 6 4 17 1
대신 내가 출력으로 점점 오전 :
Node 0 : 1 3 7 205
Node 1 : 1 2 9 205
Node 2 : 1 7 9 205
Node 3 : 2 4 6 205
Node 4 : 2 4 8 205
Node 5 : 2 1 17 205
Node 6 : 5 1 15 205
Node 7 : 5 5 1 205
Node 8 : 6 17 4 205
Node 9 : 6 4 17 205
이 파일 T1.txt입니다 :
1 3 7
1 2 9
1 7 9
2 4 6
2 4 8
2 1 17
5 1 15
5 5 1
6 17 4
6 4 17
'reqNode'에 대한 코드를 보여주십시오. –
어쩌면 나는 눈이 멀지 만 어디에도 'bool'이 보이지 않는다. – twalberg