Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- //part 1 - "Sortieren nur anders"
- // length of the answer array = arr1
- // if elements are in both arr's, then same folge
- // what is not in arr2 - same folge, but in the end
- //the elements from arr, that are not on the list, have to be written in the order in which they stay in arr
- //TODO print out such elements correctly
- otherSort(new int [] {2,3,1,3,2,4,123,6,7,9,2,19}, new int [] {2,1,4,123,3,9,6});
- }
- Scanner in = new Scanner(System.in);
- public static int[] otherSort(int[] arr, int[] arr2) {
- System.out.print("{");
- int number = 0;
- //elements e ARR, e ARR2
- for (int i = 0; i < arr2.length; i++) {
- for (int j = 0; j < arr.length; j++) {
- if (arr[j] == arr2[i]) {
- System.out.print(arr[j] + ",");
- number++;
- }
- }
- }
- //scheisse hier (da unten)
- int [] numbers = new int [arr.length];
- for (int i = 0; i < arr2.length; i++) {
- for (int j = 0; j < arr.length; j++) {
- if (arr[j] == arr2[i]) {
- numbers[i] = arr[j];
- }
- }
- }
- int notNull = 0;
- for (int i = 0; i < number; i++){
- if (numbers[i] != 0){
- notNull++;
- }
- }
- int y = 0;
- for (int j = 0; j < arr.length; j++){
- for (int i : numbers){
- // System.out.print(i + " " + j);
- if (i != 0) {
- if (arr[j] != i && arr[j] /i != 0 && arr[j] % i != 0) {
- y++;
- }
- if (y == notNull){
- System.out.print(arr[j] + ",");
- y = 0;
- }
- }
- }
- }
- System.out.print("}");
- return new int[]{};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement