I'm trying to make a program for my School homework.
it told me to divide 1 with 3, and get a result:
Quotient = 0.3
Remainder = 0.1
I've tried to use double ( result from the quotient = 0,33333333) and int ( result from the quotient = 0).
Is it possible to make such a program? Thank you.
Yes, it is possible to make such a program.
The main idea behind this program is to simulate the same way you'd do it if you were doing the division by hand on paper. Don't go looking for a simple, single math function to do this. It is a problem that's been asked this way on purpose to guarantee there's not a single type of division operator which will give you the correct answer.
Hint: remember that dividing is performed by subtracting values, shifted in places. So 1.0
is "divided by" 0.3
by 1.0 - 3*0.3
, leaving a remainder of 0.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.