Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Loader {
- private static final int MAX_CONTAINERS = 12;
- public static void main(String args[]) throws IOException {
- InputStream inputStream = System.in;
- Reader inputStreamReader = new InputStreamReader(inputStream);
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
- String sBoxes = bufferedReader.readLine();
- int containerNum = 1; // это счетчик, чтобы счет не прекращался
- int boxNum = 1; // и это тоже
- double nBoxes = Double.parseDouble(sBoxes);
- int boxesInContainers = 27;
- int containers = (int) Math.ceil(nBoxes / boxesInContainers);
- int trucks = (int) Math.ceil(containers / MAX_CONTAINERS);
- int maxBoxesInTruck = boxesInContainers * MAX_CONTAINERS;
- System.out.println("Ящиков всего: " + nBoxes);
- System.out.println("Нужно контейнеров: " + containers);
- System.out.println("Нужно грузовиков: " + trucks);
- for (int i = 1; i <= trucks; i++)
- {
- System.out.println("Грузовик" + " " + i + ":");
- while (containerNum <= MAX_CONTAINERS)
- {
- System.out.println("Контейнер" + " " + containerNum + ":");
- containerNum++;
- while (boxNum <= maxBoxesInTruck)
- {
- System.out.println("Ящик" + " " + boxNum);
- boxNum++;
- if (boxNum > boxesInContainers )
- {
- // что тут писать? И вообще правильно ли я все делаю?
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement