Home c Implementing the fission function. C / C++.

# Implementing the fission function. C / C++.

Author

Date

Category

Tell me the algorithm of fission functions on C++ or with.

Well … The task is unusual, never solved. I thought now, I can file an idea: it may be poorly implemented. How to teach to share at school: division by the column. But it turns out, it can be done only for integer division.

In the cycle:

• select the first digit;
• if less divided, take the second and i.e. until there is a number of greater than to divide;
• it is necessary to feed:
• you need to multiply the numbers from 1 to 9 per divide until you receive a number & gt; divided = & gt; the previous number is yours; In the example, on the first iteration, we get 1-ku, because `2 * 7 = 14 & gt; 13 `We are not suitable
• deduct from our number (in example 13) what the `1 * 7 `1 * 7 came with multiplication: we get 6 and again to the beginning of iteration to 6 add a new number
``````
132 | 7.
___
eighteen
7.
- = 06.
62.
56.
- = 06.
```
```
• Here the balance is not divided 6.

I filed an idea, I didn’t even write the block the scheme according to the normal, but, most likely, it is not so hard to realize, although carefulness needs. 🙂 Successes.

Sori, I tried somehow formatically write, and not coming out for some reason.

algorithm itself in the form of flowcharts can be sprinkled here:

In essence, it is a binary division in the column.

Ready functions (first, which fell, I do not know how good it is):

The division algorithms in the equipment are well described in the book “Organization of EUM” Orlova, both for integers and real.

``````# include & lt; stdio.h & gt;
Void Div (Int A, Int B)
{
int quot = 0, rem = 0;
for (int i = a-b; i & gt; = 0; i- = b)
{
quot ++;
REM = I;
}
printf ("quot =% d rem =% d", quot, REM);
}
INT MAIN ()
{
div (29,5);
}
``````

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.