C++, increasing/decreasing integer list sequence

legcramp

Golden Member
May 31, 2005
1,671
113
116
Hi there, I am making a sort program (insert sort) that takes a vector list of random, increasing, and decreasing integers. I got the random list working with the rand() command which was pretty easy, but I am having a hard time getting the list to have a pre-sorted increasing and another list with decreasing order.

(I am basically going to compare the work done / cpu clock tick between the three sequences after I get all three running)

I mean I can make a list with 20000 numbers in there and pass it into the vector but that would take forever.

Here's my random list that works great:

Code:
 srand(time(0));
    int n = 20000;
    int nums[n];
    
    for (int i=0; i<n; i++){
        nums[i]=rand()%100;
        cout<<nums[i]<<" ";

Any help is appreciated for modifying this to have an increasing and/or decreasing integer sequence instead.
 

legcramp

Golden Member
May 31, 2005
1,671
113
116
Jeez, yeah that was it, how embarassing LOL.

I don't know why I was using nums = i++ when it was already declared here:

for (int i=0; i<n; i++)

Thanks a lot!
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Code:
 srand(time(0));
    int n = 20000;
    [b]int nums[] = new int[n]; [/b]
    
    for (int i=0; i<n; i++){
        nums[i]=rand()%100;
        cout<<nums[i]<<" ";

    [b]delete[] nums;[/b]