•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 425,932 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,638 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 508 | Replies: 5
![]() |
•
•
Join Date: Sep 2007
Posts: 37
Reputation:
Rep Power: 2
Solved Threads: 0
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 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.
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,166
Reputation:
Rep Power: 38
Solved Threads: 930
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 think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Sep 2007
Posts: 37
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
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:
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;
} I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
•
•
Join Date: Sep 2007
Posts: 37
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
>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.
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,166
Reputation:
Rep Power: 38
Solved Threads: 930
>>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
>>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; I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Help - surf sidekick 3 is attacking! (Viruses, Spyware and other Nasties)
- MDI forms and their Children (Visual Basic 4 / 5 / 6)
- Singly-Linked Lists: Ultimate (C++)
- help needed in assigning values.. (C)
- This ought to be simple - extra spaces (PHP)
- Sorting arrays and then checking for duplicate characters (Java)
- After formatting, PC REALLY, REALLY slow (Troubleshooting Dead Machines)
- Set Performance Options in Windows XP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: How do I install gtkmm in dev c++ on windows?
- Next Thread: good C++ Win32 API Tutorial



Linear Mode