|
|
Exercise 2 1- Write function “Difference” that takes 2 sorted arrays of integers A and B and outputs the following: a. An array of integers “diff” that contains only the elements that are in A AND NOT in B. b. Number of elements of “diff” array. c. Boolean variable “different_in_B” that is true if there are some elements in B that is not in A (which means that B is NOT a subset of A), false otherwise Note: A and B maybe have different sizes. Note: the input arrays must not change. 2- Write a main function that: a. Asks the user to enter the number of elements of array A b. If the entered number of elements <= 0, repeat step a, otherwise go to step c c. Asks the user to enter the array elements (assume they’re entered sorted ascendingly; don’t check on their order) d. Repeats step a, b and d for array B then go to step e e. Calls “Difference” function and passes A and B as its inputs f. Prints the output “diff” and the value of the output “different_in_B” |
diff=new int[k];
diff=new int[length of A];
|
|