Untitled
unknown
plain_text
7 months ago
2.0 kB
4
Indexable
import java.util.Random;
import java.util.ArrayList;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
Random generator = new Random();
ArrayList<Integer> lentainput = new ArrayList<Integer>();
ArrayList<Integer> lentaoutput = new ArrayList<Integer>();
System.out.printf("Copyright Naniak Pavlo 123903");
// int state = 0;
for (int i = 1; i <= 30; i++) {
int k = generator.nextInt(2);
lentainput.add(k);
}
System.out.print("\n");
for (int i = 0; i < lentainput.size(); i++) {
System.out.print(lentainput.get(i) + " ");
}
System.out.print("\n");
for (int i = 0; i < lentainput.size(); i++) {
if (lentainput.get(i) == 1) {
lentaoutput.add(0);
} else if (lentainput.get(i) == 0) {
lentaoutput.add(1);
}
}
for (int i = 0; i < lentaoutput.size(); i++) {
System.out.print(lentaoutput.get(i) + " ");
}
// for (int i = 0; i < lentainput.size(); i++) {
// int q = 0;
//
// if (lentainput.get(i) == 0) {
// if (state == 0) {
// q = 0;
// state = 0;
// } else if (state == 1) {
// q = 1;
// state = 0;
// }
// } else if (lentainput.get(i) == 1) {
// if (state == 0) {
// state = 1;
// q = 0;
// } else if (state == 1) {
// state = 1;
// q = 1;
// }
// }
// System.out.print(q + " ");
// // System.out.printf("input: " + program + " output: " + q + " state:" + state + "\n");
// }
}
}Editor is loading...
Leave a Comment