/
wordsMatrixGenerator
161 lines (138 loc) · 4.85 KB
/
wordsMatrixGenerator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import java.io.IOException;
import java.util.ArrayList;
public class main_class {
public static void main(String[] args) throws IOException {
ArrayList<String> list = new ArrayList<>();
list.add("ОДИН");
list.add("ДВА");
list.add("ДВЕ");
list.add("ТРИ");
list.add("ЧЕТЫРЕ");
list.add("ПЯТЬ");
list.add("ШЕСТЬ");
list.add("СЕМЬ");
list.add("ВОСЕМЬ");
list.add("ДЕВЯТЬ");
list.add("ДЕСЯТЬ");
list.add("НАДЦАТЬ");
list.add("ЧАС");
list.add("ЧАСА");
list.add("ЧАСОВ");
list.add("ТРИ");
list.add("ДВА");
list.add("ДЦАТЬ");
list.add("СОРОК");
list.add("ПЯТЬ");
list.add("ДЕСЯТЬ");
list.add("ОДНА");
list.add("ОДИН");
list.add("ДВЕ");
list.add("ТРИ");
list.add("ЧЕТЫРЕ");
list.add("ПЯТЬ");
list.add("ШЕСТЬ");
list.add("СЕМЬ");
list.add("ВОСЕМЬ");
list.add("ДЕВЯТЬ");
list.add("НАДЦАТЬ");
list.add("МИНУТА");
list.add("МИНУТЫ");
list.add("МИНУТ");
int horizontalCount = 41; // переменная отвечает за количество символов в строке.
// Меняя её можно добиться нужной длины и количества строк в матрице
int counter = 0;
String total = null;
String combinations = null;
String words = null;
boolean isFirstLine = false;
for (int i=0; i<list.size(); i++)
{
total = total + list.get(i);
}
total = total.substring(4);
System.out.println("Длина строки(символов): " + total.length());
for (int i=1; i<=total.length(); i++)
{
if (total.length()%i==0)
{
combinations = combinations + " " + i;
}
}
combinations = combinations.substring(4);
System.out.println("Возможные комбинации символов в строке (забивать в переменную horizontalCount):" + combinations );
char [] chars;
chars = total.toCharArray();
System.out.println();
System.out.println("Как будет выглядеть матрица слов:");
System.out.println();
for (int i=0; i<chars.length; i++)
{
counter++;
if (counter<horizontalCount)
{
if (i==0)
{
words = (String.valueOf(chars[i])) + " ";
}
else
{
words = words + String.valueOf(chars[i]) + " ";
}
}
else if (counter==horizontalCount)
{
words = words + String.valueOf(chars[i]);
if (!isFirstLine)
{
System.out.println(words);
isFirstLine =true;
}
else
{
System.out.println(words.substring(4));
}
System.out.println();
counter=0;
words=null;
}
}
isFirstLine = false;
System.out.println();
System.out.println("Как будет выглядеть матрица номеров светодиодов в ленте:");
System.out.println();
for (int i=0; i<chars.length; i++)
{
counter++;
if (counter<horizontalCount)
{
if (i==0)
{
words = i + " ";
}
else
{
words = words + i + " ";
}
}
else if (counter==horizontalCount)
{
words = (words + i);
if (!isFirstLine)
{
System.out.println(words);
isFirstLine =true;
}
else
{
System.out.println(words.substring(4));
}
System.out.println();
counter=0;
words=null;
}
}
isFirstLine = false; //"для порядку"- пущай будет;-).
// Вдруг ниже надуемается что-то дописать в будущем.
// Чтобы не забыть про эту переменную.
}
}