Cathy
2012-11-21 05:29:14 UTC
Honestly, I don't even know where to begin. I've searched the whole internet for clues and my lecturer's notes are a joke and i'm seriously so desperate right now! I've made an attempt at it, but i'm not even sure if it should look like this because i have to include a sorting array and i don't know how to do that.
Write a program that:
•1) Creates an array containing 100 random double numbers in the [0,250) range;
•2) Sorts them in descending order;
•3) Prints the contents of the sorted vector out. The sorting should be coded as a separate function double* sort_array(double* ).
The program i made prints 100 random numbers from 1-250, i need it to do that in a descending order.
please help!
#include
#include
using namespace std;
//no idea where to put a sorting array.
int main()
{
double nums[100];
int a, b, t;
double size=100;
for (t=0; t
for (a=1; a
if (nums[b-1] > nums[b]) {
t = nums[b-1];
nums[b-1] = nums[b];
nums[b] = t;
}
}
}
for (t=0; t
return 0;
}