Answer the question
In order to leave comments, you need to log in
How to correctly implement the definition formula?
Hello guys, there is a task:
There is a nine-story building with 4 entrances. The entrance number starts with one. There are 4 apartments on one floor. Write a program that will receive the apartment number from the keyboard and display on the screen on which floor, which entrance this apartment is located. If there is no such apartment in this house, then you need to inform the user about it.
An example formula is:
X - apartment number 4*9=36
entrance number X div 36 + 1st
floor (X mod 36) div 4 + 1
Answer the question
In order to leave comments, you need to log in
(21 - 1)% 36 / 4 + 1 = 6; (6th Floor)
Why 4+1 if there are 9 floors
(21 - 1) % 36 / 4 + 1 = 6; (3rd floor)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question