Hey guys, I'm in a bowling league and I need to code a program to help sort/assign points to the scores.
I do web design/graphic design
so if anybody can help me at all I will be glad to help any of you with any web/graphic needs.


Lets say theres 5 bowlers,
I need to have 5 separate
cout << "John Smith: "; (where the user will enter the score for each bowler separately)

then after all the scores have been inputted, I need the program to have it sorted ascending.

LASTLY, I need "points" to be assigned.

If there are 5 bowlers, the highest score gets 5 points,
then the 4th bowler gets 4, etc, etc.
But if the score is 0, then they get 0 points.

I would use a structure to hold the information for each bowler, then after entering the information sort the array of structures by score. After that print the array information.

struct bowler
{
    std::string bowlername;
    int score;
    int points;
};

I would use a structure to hold the information for each bowler, then after entering the information sort the array of structures by score. After that print the array information.

struct bowler
{
    std::string bowlername;
    int score;
    int points;
};

Well.. I wouldn't know how to do the rest then....
how do I get the program to sort the scores and then automatically assign points accordingly to the rank?

>Well.. I wouldn't know how to do the rest then....
Well, let's start over. What do you know? We're not mindreaders, so there's no way to tell how much hand holding you need or expect.

>how do I get the program to sort the scores
Oddly enough, C++ has a function called std::sort.

>then automatically assign points accordingly to the rank?
Well, it sounds like you want points to match the index of the sorted array, so I would make an educated guess that it's quite trivial to assign the points once you've sorted the array:

for ( int i = 0; i < n; i++ ) {
  if ( bowler[i].score == 0 )
    bowler[i].points = 0;
  else
    bowler[i].points = i + 1;
}

>Well.. I wouldn't know how to do the rest then....
Well, let's start over. What do you know? We're not mindreaders, so there's no way to tell how much hand holding you need or expect.

>how do I get the program to sort the scores
Oddly enough, C++ has a function called std::sort.

>then automatically assign points accordingly to the rank?
Well, it sounds like you want points to match the index of the sorted array, so I would make an educated guess that it's quite trivial to assign the points once you've sorted the array:

for ( int i = 0; i < n; i++ ) {
  if ( bowler[i].score == 0 )
    bowler[i].points = 0;
  else
    bowler[i].points = i + 1;
}

Okay so I know the basic C++ stuff. Simple Input/processing/Output stuff.

From what I know I'll do this

int main ()
{
//Input
cout << "Enter John Smith's Score: ";
cin >> johnsmith;
cout << "Enter Jane Doe's Score: ";
cin >> janedoe;

Then its the processing that I dont know what to do.
That code you sent me,
Is that all I put in the processing?
I mean.. What does the "i" and the "n" and the "++" represent??


I'm sorry for being such an amateur, it must be annoying.
i'm trying my hardest, but at this point I think i just need somebody with more knowledge to help me.

>>What does the "i" and the "n" and the "++" represent??

>>Okay so I know the basic C++ stuff

If you new the basic c++ stuff you would not need to ask that question. So I suggest you go back and re-read your text book, and read it as often as necessary until you have a good handle on the basics. I nearly wore the pages of my book out during my first year of programming.

The ++ is a shorthand operator to increment a variable and is the same thing as i = i + 1;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.