You should read the FAQs we all are here to help but we cannot do homework perhaps you should edit this thread an add the code of what you have tried so far, and the we could be more helpfull.
i think in the first one that you will need a for asking for random number for the user to input and save them all in an array [] and then with another for with an if inside you could manipulate them easily call the second one might be the bubble method but i didnt quite understand what you are needed to do if you upload your code i could help .