If any one has a problem with this exercise here is my solution
Code:
// Solu4_4.cpp : main project file.
/* The exercise was to create an array with a random number between 10
to 20 elements with values ranging between 100 and 1000 values. The
author did not want the array sorted by Array::Sort. After checking
several books on C++ for sorting there was no solution. I check on
a book for C programming and found several sort methods including
Exchange, Selection and Insertion. One sort that I used here is an
exchange sort called "The Bubble Sort".
*/
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
// Generate a number between 10 and 20 and store it in count.
Random^ generator = gcnew Random;
int count = generator->Next(10,20);
// Print the number of values generated.
Console::WriteLine(L"The number of items generated is {0}",count);
// Now create an array of values containing the number generated.
array<int>^ values = gcnew array<int>(count);
// Now filled an array with the number of values in count.
for(int i = 0; i < count; i++)
values[i] = generator->Next(100,1000);
// Now we sort the values using "The Bubble Sort".
int temp = 0; // Temporary store for values.
for(int x = 1 ; x < count; ++x)
for(int i = count-1; i >= x; --i)
{
if(values[i-1] > values[i])
{
temp = values[i-1];
values[i-1] = values[i];
values[i] = temp;
temp = 0;
}
}
// Now print out sorted ascending values five to a line.
for(int i = 0; i < count; i++)
{
Console::Write(L"{0,10}",values[i]);
if((i+1)%5 == 0)
Console::WriteLine();
}
Console::WriteLine();
return 0;
}