Question: Write a function called extract_prime() that takes the three vector arrays holding all the random numbers and the boolean variables indicating which are primes as
Write a function called "extract_prime()" that takes the three vector arrays holding all the random numbers and the boolean variables indicating which are primes as input and produces a new vector of just the prime numbers.
Write a function called "print()" which prints the contents of an array in a formatted fashion as shown below. Specifically, print 8 integers per line in a 3-character wide field with a space separating the numbers. Add code that calls these two functions to output the prime numbers in their order of appearance. Then sort the data and eliminate any multiples of the same number. Output the result.
Consider using "sort()" and "unique()" from STL to do the heavy lifting. Hint: If you implemented "Prime4" using vector arrays, you can use the "erase" member function to get rid of the unwanted data moved to the end by "unique()".
Output as expected:

Prime4 user ./Prime4 Sequence contains 21 prime numbers. All numbers in order appearance: 61 113 13 534117 61 97 59 7 17 137 415 127 31 131 59 109 83 61 Unique values in numerical order: 5 7 13 17 314153 59 61 83 97 109 113 127 131 137 user> user /Prime4 1000 Sequence contains 243 prime numbers. All numbers in order appearance: 37 11 3 79 59 11 47 97 7 17 109 59 2283 59 113 89 61 73 41 31 79 1774331 53 7 17 83 11 31 3 127 43 101 139 137 109 5 17 5 192931 17 107 131 61 113 783 23 109 41 19 7953 47 139 103 59 67 3 113 137 137 73 29 127 23 109 103 37 127 139 107 101 11 2 139 11 23 10753 127 59 109 13 13 139 101 714171 139 131 127 89 109 127 83 137 43 43 73 113 61 3 79 29 97 767 97 5 137 31 109 67 89 83 27 6729103 5 31 41 37 19 131 109 11 71 11 13 674779 2 131 17 127 261 11 29 23 47 2919 5 101 137 67 11 47 13 139 43 113 127 113 3 31 67 79 107 53 13 13 7 83 103 7173 89 29 131 61 41 101 79 31 12743 83 47 139 43 89 41 3 89 11 7 113 13 13 2 17 53 139 113 59 23 19 59 103 73 5 103 737 8971 73 131 103 6761 137 41 43 109 5 127 11 17 139 3141 73 43 29 235 47 79 127 Unique values in numerical order: 5 7 11 13 1719 23 29 31 37 4143 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127131 137 139
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
