Click to See Complete Forum and Search --> : display elements in an array in order
dalon
01-26-2001, 08:01 PM
I need to know how to make the elements of an array be displayed on the screen
from high to low. I am in a c++ class and I am having trouble with getting
it right.
I do appreciate any help, thank you.
Danny Kalev
01-26-2001, 11:38 PM
use a reverse loop that starts with a counter that is equal to the
array's size and display the elements with that index, then decrement
the counter and display the next element (i.e., the one below the
previously displayed element) and so on.
Danny
dalon wrote:
>
> I need to know how to make the elements of an array be displayed on the screen
> from high to low. I am in a c++ class and I am having trouble with getting
> it right.
>
> I do appreciate any help, thank you.
chris
01-27-2001, 08:30 AM
if 'from high to low' means from the end of the array to the beginning of
the array, then danny is correct.
for some reason, i got the impression that you wanted to print the array
element with the highest value first all the way down to the array element
with the lowest value. if this is what you want, you may want to look into
using the set class from the std lib.
Danny Kalev <dannykk@inter.net.il> wrote:
>use a reverse loop that starts with a counter that is equal to the
>array's size and display the elements with that index, then decrement
>the counter and display the next element (i.e., the one below the
>previously displayed element) and so on.
>
>Danny
>
>dalon wrote:
>>
>> I need to know how to make the elements of an array be displayed on the
screen
>> from high to low. I am in a c++ class and I am having trouble with getting
>> it right.
>>
>> I do appreciate any help, thank you.
CodeZombie
01-28-2001, 10:55 AM
"dalon" <mpetti1316@aol.com> wrote:
>
>I need to know how to make the elements of an array be displayed on the
screen
>from high to low. I am in a c++ class and I am having trouble with getting
>it right.
>
>I do appreciate any help, thank you.
Oki Doki. First of if you want to display an array from High to Low you need
to sort it first, and then you would put it into a for loop just like this:
for(int z=0; z<=totalnumberofelements; z++)
{
cout<<array[z].name<<endl;
}
Again you might wanna change some thing in here.
See ya DOLPHINS!
:)
devx.com
Copyright Internet.com Inc. All Rights Reserved