a) Write a function named prime which has 1 parameter (int n). The function returns 1 if n is a prime number else 0. [done]
b) Write a program that cin>>n (n<30) and after that the user enters n numbers. Using function prime the function main must cout only the prime numbers from those entered by the user. The numbers must be sorted in increasing order.
Ex: n=7 input: 3 16 41 4 2 7 12,
output: 2 3 7 41
I know how to do this one with arrays, but do you guys know any easier, more efficient way of sorting them?
well arrays are simple enough, other option is vectors but they are more complicated. if you want to push it you COULD do data structures but arrays are your simplest option.
... I thought vectors are the same with arrays... in this case I know how to do it with vectors ( int vector[], counter, n; cin>>n; for(counter=1;counter<=n;counter++)...