12345678 |
- let floorsInTheHouse = 9;
- const numberOfApartmentsPerFloor = 4;
- let apartmentNumber = +prompt('Укажите номер квартиры');
- let entranceNumber = Math.ceil(apartmentNumber / (floorsInTheHouse * numberOfApartmentsPerFloor));
- let floorNumber = Math.ceil((apartmentNumber % (floorsInTheHouse * numberOfApartmentsPerFloor)) / numberOfApartmentsPerFloor);
- alert(`Номер подезда - ${entranceNumber}, этаж = ${(floorNumber === 0) ? (floorNumber = floorsInTheHouse) : floorNumber}`);
|