FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Yes yes! Highest grade on a test in over THREE YEARS!!!! programmers invited

   
Author Topic: Yes yes! Highest grade on a test in over THREE YEARS!!!! programmers invited
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
99%!!! I can't even remember the last time I got a mark so high! its worth 40% of my grade!

Also anothe rmoral boost I had was that I have to write a program that converts infix to postfix, the second version I had to make is supposed to be full of stubs but the output its supposed to look like this:
eg:
INFIX POSTFIX VALUE
. . 13.675
. . .
A+B*C AB+C* .
. . .


Basically I'm given a prechosen list of Infix strings in an array which I made a global and I supposed to out put them in a for loop and basically a final value of a random number of some kind (remeber evaluating the postfix expressions is just a stub function so it will for the time being return a float).

There's a loop that looks like this:

printf "%-30s etc etc etc\n", "INFIX, POSTFIX, VALUE"

for int j = 0; j < LSIZE, j++
{ //ifx is infix holding buffer
. strcpy{ ifx, infix{j}}; //infix is string array of infix expressions
. infixindex = j; //making the index
. convert{ ifx, pfx } //converts infix to postfix
. pfval = Eval{pfx};
}


now the conversion function is a stub inside it are postfixes already in a postfix array and will each time the loop runs spits out each postfix one at a time.

Here was my problem, the postfix array was inside a function, and was only sending it out one at a time. The output loop would only fire after the loop mentioned above finished going through each infix and postfix string.

So how do I store all of them?

Eventually all on my own I initialized an empty array for postfix and has it so that each time a postfix was spat out it was string copied into the new postfix array.


As such I added strcpy{ postfix{j}, pfx } to after the conversion function was called to handle the job.

Problem still remaining: Aside from now needing to get a fully working pop/push stack algorthm going...


cout << setw{-24} << infix{j} << setw{25} << postfix{j} << setw{30} << pfval << endl;

It aligns the INfex and postfix strings perfectly but the Pfval string isnt they are push the setw distance away from the postfix strings X amount x being the size of the postfix string for some reason.

IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Just me or is this forum really not programmer friendly with this no paranthesis inside html tag thingy
IP: Logged | Report this post to a Moderator
twinky
Member
Member # 693

 - posted      Profile for twinky   Email twinky         Edit/Delete Post 
You can use code tags, which gives you a fixed-width font. It's just like bold or italic tags, only the result looks like
code:
this

[Smile]
Posts: 10886 | Registered: Feb 2000  |  IP: Logged | Report this post to a Moderator
erosomniac
Member
Member # 6834

 - posted      Profile for erosomniac           Edit/Delete Post 
Congratulations, Blayne! ^_^
Posts: 4313 | Registered: Sep 2004  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2