i" am taking c++ class now and I am strugling with that problem.
here is the part i have problem with
Program will put the numbers in order and print the sorted list. First in the incremental, later in the decremented order.
so when i trying to print the sorted list in decremental and decremented order i cant get it. he keeps giving me the same number. please can someone gives an idea
int main()
{
int i,n, j, x, y;
double number [10] = {};
cout << "how many number do you want to key in?" << endl;
cin >> n ;
for (i=0; i<n; ++i )
{
cout <<"enter your numbers:"<< endl;
cin >> number [n];
}
for (i=0;i<n;++i)
{
for (j=1;j<n;++j)
{
if (number[i]>number[j])
{
x=number[i];
number[i]=number[j];
number[j]=x;
}
}
}
cout << "Here is the incremental order of your number :" << x << endl;
cin.get ();
for (i=0;i<n;++i)
{
for (j=i+1;j<n;++j)
{
if (number[i]< number[j])
{
y=number[j];
number[j]=number[i];
number[i]=y;
}
}
}
cout << " here is the decremented order of your given numbers:" << y << endl;