Link to home
Start Free TrialLog in
Avatar of netminder
netminder

asked on

Need to confirm

I just did this problem also...

I want the contents of the queue Q after the first loop, then I want the output of the following code..

int i, n;
typedef int queueItemType;
queueClass Q;
for(i=1;i<=5; i++)
Q.QueueAdd(i, Success);
for(i=1;i<=5;i++0
{
Q.GetQueueFront(n, Success);
Q.QueueRemove(Success);
cout<<n;
}
cout<<endl;
Avatar of Shay050799
Shay050799

what ?#$@#$%$##
is this english or what ?

explain...
Avatar of netminder

ASKER

Basically I was looking for the output created after the first loop of the program. Then I wanted the ouput at the end of the program.
This seems like homework. According to the EE customers agreement we can't do your homework for you.
Homework it isn't. I have a learn c/c++ book I borrowed from
my library. The only unfortanate thing is that somebody needed to take out the answer section.
dear netminder yonat is joking with you don't worry.
and yonat what are u doing online friday night ? huh
go to a Tel Aviv Pub or something :-)

Netminder give me a minute
we need more code of it... what is success ?
Without knowing exactly what this queueClass does (I have no idea what Success is, where it defined, or what purpose it serves), I would guess that after the first loop, Q would contain the integers: [ 1,2,3,4,5 ].

I would also guess, again, not knowing anything about these functions except their names, that the output of the code would be:

12345

And this is C++.
the code is mixed up according to the little program the output is:
55555 cause the second loop is i not n
netminder, sorry for assuming it was homework - it just looked this way.

Shay,
> yonat what are u doing online friday night ? huh
> go to a Tel Aviv Pub or something :-)

That would be difficult, since I live near Qiryat Shemona...
yonat:
really ? where ?

As far As I can tell Success just confirms that the operation was succesful. As for giving more code, that's it. I probably could have borrowed a better book. Thanks for all the help though.
Q.GetQueueFront(&n, Success);
Hi Shay,
I live in Kibutz Maayan Baruch. BTW, you can mail me at yonat@usa.net (so netminder will not have to read through our boring comments...)
Shay, do you happen to live in Tel-Aviv or somewhere around Tel-Aviv ?

Arnon David.
(sarnon@t2.technion.ac.il)
Ahoffmann's,

I appreciate your response, but I was lokking for the numerical output.

Thanks anyway
what do you mean by "numerical output"?
Your posted code can't do it right, 'cause of the value parameter (except you have a sophisticated compiler ;-)
ASKER CERTIFIED SOLUTION
Avatar of Laminamia063099
Laminamia063099

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note: The queue contents after each remove is NOT output to the screen.  I just added them to show you how the queue looks before and during the second loop.

Laminamia
Laminamia, if we were doing a cout<<Q, then I would agree with you.  But that doesn't appear to be what's happening.  n is an int, as such it could not be a Queue unless the GetQueueFront function did some strange casting.

Sorry I was confusing.  The output that I have written is the integer n that is removed from the queue each time.  The queue contents that I included were to clarify what was happening to the queue, not as part of the cout output.  

The output of this program is:
1    2     3     4     5

There is no endl with each cout, and each cout outputs the front-most member of the queue that was interrogated and removed in the loop.
 
I hope this clarifies my answer.
I see where my answer sounds confusing.  The oldest member of the queue, or the frontmost integer in the queue is interrogated with GetQueueFront.  NOTE:
>>1 2 3 4 5
>>2 3 4 5
>>3 4 5
>>4 5
>>5
This is only the queue contents during the loop.  This is not output to the screen.  I included it to help out netminder.  

Laminamia :)
*smile*  If you'll look at my first comment, I think you'll see that I agree 100%.
(: Oops :)
(Sometimes I miss some of the comments when there are so many).

Laminamia