Posted: 6/20/2006 5:20:28 PM EDT
I'm trying to write a C++ program that will graphically display the actual steps of longhand division, just like you would write it on paper. I dont even know where to begin, except for the actual calculation. Here's the code I have so far:#include <iostream> |
He is asking how to graphically display, I assume like Mathmatica or Mathcad or something... |
|
I would suggest actually doing a longhand division problem by hand. Do some with remainders and with numbers with different orders of magnitude. Then from that you can get an idea for your algorithim. Its going to require subtraction and integer division. You will need some code to do the input and some code to do the formatting of your outputs. |
No, I understood him to mean that the program would do this:
eta: Thank christ I am no longer in college. |
Yep this is a stupid COMP SCI homework problem. I'm having trouble coming up with the logic on how to calculate and display the problem like you would write it on paper. Ex: 6)500 = 83R2 -48 ------- 20 - 18 ------- 2 |
|
But the dumb prof wants it shown.. he wants to see -> "ok.. well, 4 won't go into 3, so throw on a decimal and put a zero after the 3, then see how many times 4 will fit.."? This is why we have computers for in the FIRST place! To CAWM-PEWT things. Edit: Use bit-shifting!
|
| Well I'm not going to write it for you but essentially you need to perform a division, keep the quotient and display it as the first digit. Then take the remainder (using modulo operator) and multiply it by 10. Then redivide and keep looping this until you reach a predetermined decimal place or the remainder is 0. |
Yep, thats what the prof wants. Can't come up with the logic. |
Tell him the Internet thinks he is a fucking moron. |
Thanks, big help. |
