How to sort in descending order after generating random numbers between 0 & 99

#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
using namespace std;

class NumberSort{
int i, j;
int temp;
public:
Sort(int a[],int n);

};

void NumberSort::Sort(int a[], int n)
{
for (i=0; i<n-1; i++){
for (j=1; j<n-1; j++){
if (a[j-1] < a[j]{
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
}
}
}

void main()
{
int i, s;
int RANGE_MIN=0;
int RANGE_MAX=99;
int randno[50];
int sortno[50];
for (i=0; i<50; i++)
{
randno[i] = (int) (((double)rand() /
(double) RAND_MAX) * RANGE_MAX + RANGE_MIN);
cout<<randno[i]<< " ";
}
cout<<endl;
NumberSort x;
sortno[50] = x.Sort(randno[], s=50);
cout<<"Numbers in descending order:\n";
for (i=0; i<50; i++)
{
cout<<sortno[i]<< " ";
}
}
thkim36
Asked Nov 25, 2009

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Categories