Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.out.println("Количество вершин многоугольника:");
- int n = sc.nextInt();
- //StringBuilder[] mas = new StringBuilder[n + (n - 3)];
- //Ой! NullPointerException! Не знаю, почему он тут вылез, так и не понял.
- String[] mas = new String[n + (n - 3)];
- int q = 0;
- for (; q < n - 1; q++) {
- //mas[q]=new StringBuilder();
- mas[q] = "" + (q + 1) + "-" + (q + 2) + " ";
- }
- mas[q] = n + "-1 ";
- q++;
- System.out.println("Вводите диагонали (пара вершин):");
- for (int i = q; i < n + (n - 3); i++) {
- //mas[i]=new StringBuilder();
- mas[i] = sc.nextInt() + "-" + sc.nextInt() + " ";
- }
- System.out.println("Ввод завершён\n_____________");
- for (int i = 0; i < n + (n - 3); i++) {
- if (i < q) {
- mas[i] += "Red";
- } else {
- mas[i] += "Blue";
- }
- }
- for (int i = 0; i < n + (n - 3); i++) {
- System.out.println(mas[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment