0

Okay, I need my output to be numbered.
I know the index code works but idk how to use that.

However, i also need to know how to do the if/else statement,
so that if the output is "0", then they dont get an index, they just recieve "0"

3
Contributors
6
Replies
7
Views
10 Years
Discussion Span
Last Post by Narue
0

Presumably you mean you have something like:

string array[]={"boo","hoo","shoo"};

And you as you print it you want to print their indexes, i.e

[1] boo
[2] hoo
[3] shoo

In that case you can do

for (int i = 0; i < max; i++ )
{
cout << "[" << i+1 << "]" <<array <<endl;
}

But like narue said it is hard to tell what you mean.

0

Ok.

I have scores as my output,
and I want to descendingly number them down to 1.
Like as if I were ranking them.

However, if the score is "0",
I want them to be ranked as "0".

Make sense?

0

ok. How do I do the "if" statement for the people who received "0". I want to rank them as "0" instead of 1-20.

0

>Make sense?
Yes, and I'm reasonably sure I've described how to do this to you before. Anyway, it makes more sense in this case to separate the scores that are zero into a separate list. This trivializes the rankings because you can just take the number of non-zero scores and rank them down from that number, then fill out the zero scores with "0".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.