I have two arrays:
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [2, 4, 6, 8, 10]
How is it possible to make the output look like this?
list3 = [1, 3, 5, 7, 9]
list3[i] = list1[i] - list2[i];
Unfortunately this does not work for me because the two arrays are not same length.
import java.util.Arrays;
import java.util.Scanner;
public class Infinity {
public static int[] InitialiseStudents(int[] students) {
for (int i = 0; i<students.length; i++){
students[i] = i+1;
}
return students;
}
public static int[] AssignJobs (int[] NumberStudents) {
int StudCount = NumberStudents.length;
int[] Array = NumberStudents;
//loop for every day(t), starting at the second day
for (int t = 2; t <= StudCount; t++) {
System.out.println("Tag" + t);
int[] copy = new int[5];
for (int i = t-1, j=0; j < 5; i+=t) {
copy[j++] = Array[i];
}
System.out.println("-------------");
System.out.println(Arrays.toString(copy));
System.out.println("_________");
break;
}
return Array;
}
public static void main( String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter Number of Students: ");
//int n = scan.nextInt();
int n = 10;
int[] students = new int[n];
InitialiseStudents(students);
students = AssignJobs(students);
System.out.println(Arrays.toString(students));
}
}
To make to task VERY clear I just show you everything I have done and the context. This is my homework which I am curently working. The task is...
Initially, a numbering 1, 2, 3, 4, . . . of the students is determined. Then it will be that every second (start counting with the first student) becomes Garbage officer (these are the students with the numbers 2, 4, 6, 8, . . . ), from the rest (students 1, 3, 5, 7, . . . ) every third person becomes a refrigerator representative (these are students 5, 11, 17, 23, . . . ), of the rest (students 1, 3, 7, 9, . . . ) every fourth . . . , from which then we can think of something for each k-th and from the rest for every (k+1)-th etc. Apparently, some of the residents (students 1, 3, 7) omitted during distribution and do not have to complete any of the tasks that arise. Numbers of these students are called Omitted Numbers. Program an application OmittedNumbers that exactly the Omitted Numbers an area 1; : : : ;N retrieves and prints, where N is passed on the command line will. Only use methods that are iterative.
SetandSet.removeAllinstead.