Skálakatalógus
Futtatható Java-kód a skálakatalógus (rendezett) listázására
Az alábbi futtatható Java-kód a Pénzes-féle bináris skálakatalógust listázza ki, még pedig növekvő (egyre több hangos) rendezéssel. Ezt már régóta szerettem volna implementálni.
import
java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> store1 = new ArrayList<String>();
ArrayList<String> store2 = new ArrayList<String>();
ArrayList<String> store3 = new ArrayList<String>();
ArrayList<String> store4 = new ArrayList<String>();
ArrayList<String> store5 = new ArrayList<String>();
ArrayList<String> store6 = new ArrayList<String>();
ArrayList<String> store7 = new ArrayList<String>();
ArrayList<String> store8 = new ArrayList<String>();
ArrayList<String> store9 = new ArrayList<String>();
ArrayList<String> store10 = new ArrayList<String>();
ArrayList<String> store11 = new ArrayList<String>();
ArrayList<String> store12 = new ArrayList<String>();
int count = 1;
int countGroups = 1;
for (int a = 0; a <= 1; a++){
for (int b = 0; b <= 1; b++){
for (int c =
0; c <= 1; c++){
for (int d = 0; d <= 1; d++){
for (int e = 0; e <= 1; e++){
for (int f = 0; f <= 1; f++){
for (int g = 0; g <= 1; g++){
for (int h = 0; h <= 1; h++){
for (int i = 0; i <= 1; i++){
for (int j = 0; j <= 1; j++){
for (int k = 0; k <= 1; k++){
for (int l = 0; l <= 1; l++){
String str_a = Integer.toString(a);
String str_b = Integer.toString(b);
String str_c = Integer.toString(c);
String str_d = Integer.toString(d);
String str_e = Integer.toString(e);
String str_f = Integer.toString(f);
String str_g = Integer.toString(g);
String str_h = Integer.toString(h);
String str_i = Integer.toString(i);
String str_j = Integer.toString(j);
String str_k = Integer.toString(k);
String str_l = Integer.toString(l);
String store = str_a + str_b + str_c + str_d + str_e + str_f
+ str_g + str_h + str_i + str_j + str_k + str_l;
int numberBits = 0;
for(int iterator = 0; iterator < store.length(); iterator++) {
char result = store.charAt(iterator);
if(result == '1'){
numberBits++;
}
}
switch (numberBits) {
case (1): store1.add(store); break;
case (2): store2.add(store); break;
case (3): store3.add(store); break;
case (4): store4.add(store); break;
case (5): store5.add(store); break;
case (6): store6.add(store); break;
case (7): store7.add(store); break;
case (8): store8.add(store); break;
case (9): store9.add(store); break;
case (10): store10.add(store); break;
case (11): store11.add(store); break;
case (12): store12.add(store); break;
}
}
}
}
}
}
}
}
}
}
}
}
}
System.out.println(countGroups + " hangból álló hangcsoport:");
for(int i = 0; i < store1.size(); i++) {
System.out.println(count++ + ". - " +
store1.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store2.size(); i++) {
System.out.println(count++ + ". - " +
store2.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store3.size(); i++) {
System.out.println(count++ + ". - " +
store3.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store4.size(); i++) {
System.out.println(count++ + ". - " +
store4.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store5.size(); i++) {
System.out.println(count++ + ". - " +
store5.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store6.size(); i++) {
System.out.println(count++ + ". - " +
store6.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store7.size(); i++) {
System.out.println(count++ + ". - " +
store7.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store8.size(); i++) {
System.out.println(count++ + ". - " +
store8.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store9.size(); i++) {
System.out.println(count++ + ". - " +
store9.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store10.size(); i++) {
System.out.println(count++ + ". - " +
store10.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store11.size(); i++) {
System.out.println(count++ + ". - " +
store11.get(i));
}
System.out.println();
System.out.println(++countGroups + " hangból álló
hangcsoport:");
for(int i = 0; i < store12.size(); i++) {
System.out.println(count++ + ". - " +
store12.get(i));
}
}
}
Eredménylistája - annak hossza miatt-, a következő fejezetben tanulmányozható.