0
我已經包含數字兩個隊列,integerQueue只包含整數,realQueue包含開始 ''然後是以下數字。
我需要打印出整數隊列如果只整數已經在 被讀取,但如果realqueue中有數據,我需要打印出上半年integerqueu那麼下半年realqueu做一個真正的數字,如123.234
目前我的代碼將打印真正1.然後將打印整數:2342343
我怎麼能解決這個問題,從而顯示正確的輸出?
//if the realQueue is empty, then we just read in an integer, currentState must be 1, in order to print integer
if(realQueue.empty() || currentState == '1')//implementation of the FSM
{
writeFile <<"Integer: ";
while(!integerQueue.empty())
{
writeFile <<integerQueue.front();
integerQueue.pop();
}
}
//since the realQueue has values in it, then it must bea real Number
else
{
//currentState = '2';
// currentState must be == '2', since we have a real number to print
writeFile<<"Real: ";
//currentState has to be in real mode for it to print out to file
/*while(!integerQueue.empty() && currentState == '2')
{
writeFile <<integerQueue.front();
integerQueue.pop();
}*/
// currentState has to be in real mode for it to print out to file
while(!realQueue.empty() && currentState == '2' && !integerQueue.empty())
{
writeFile <<integerQueue.front()<<realQueue.front();
integerQueue.pop();
realQueue.pop();
}
}