C/C++ >> Final Exam Time!
Posted by Driver on 14:44:00 04-18-2002
Hey Guys, was wondering if one of you could explain this question that was on last year's final exam for my C programming class, I don't fully understand what I should be writing!

Draw a finite state automation that accepts complex #s. (A complex # has the form of a+bi or a-bi, where a & b are real #s)

If anyone could help, that'd be great! If not, it's all good! [addsig]
Posted by KaGez on 18:00:00 04-19-2002
to be honest, I have _no_ idea what this is about :/
sorry, can't help you
[addsig]
Posted by GG4 on 02:51:00 05-12-2002
Read in the info as a string. Then, check if the individual characters are numbers. If they are, you just keep incrementing a counter. Once you find the + or - sign, use the rules of exponents to store the a value in an int (or long if it is that big). From there, you do the same thing again, but this time, you look for the i. Also, if you get a - instead of a plus, don't forget to negate the value. Another tip, don't forget to error check in case there is a character that is not allowed inputted.

Or you could just overload the extraction operator for your complex class.

Or you could just have a bunch of cin and cout statements. It all depends on how advanced you are in programming.
Posted by Flikm on 11:14:00 05-13-2002
i had a similar problem before. what i did was input as a string that split it where you find the character.