473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Highscore system

17
Im sitting at home tryin gto learn some c++ form what i can read of the internet, so if some of the code looks familiar its probably from some tutorial out there.

So...I think i got the basic basics down and im trying to move on to dimensonal arrays. I've read about it so i have teh basic idea down.

Im trying to make a highscoresystem and have gotn this far. But i want my arrays to store both an index number, name, and score for the player. How do i do that?

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main (int argc, char** argv)
  7. {
  8.     vector<double> doubleVector(10); //create a vector of 10 doubles
  9.     double max;
  10.     int i;
  11.  
  12.     for (i = 0; i < 10; i++) {
  13.         doubleVector[i] = 0;
  14.      }
  15.  
  16.     //Read the first score before the loop in order to initialize the max
  17.     cout << "Enter score 1: ";
  18.     cin >> doubleVector[0];
  19.     max = doubleVector[0];
  20.  
  21.     for (i = 1; i<10; i++) {
  22.         cout << "Enter score " << i + 1 << ": ";
  23.         cin >> doubleVector[i];
  24.         if (doubleVector[i] > max) {
  25.             max = doubleVector[i];
  26.         }
  27.     }
  28.  
  29.     sort(doubleVector.begin(), doubleVector.end());
  30.  
  31.     for (i = 0; i < 10; i++) {
  32.         cout << doubleVector[i] << " ";
  33.     }
  34.  
  35.     cout << endl;
  36.     return 0;    
  37. }

thanks
Jun 7 '07 #1
3 1762
DeMan
1,806 1GB
Hi Moezzie ,

Welcome to thescripts. You will find a variety of forums on different topics available through the links on the blue bar near the top of this screen.

I will move this post to the c/c++ forum for you, and hopefully a c/c++ expert will be able to address you query. I hope they can help you with your problem!
Jun 7 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
The only mechanism for grouping data together is a class.

Expand|Select|Wrap|Line Numbers
  1. class Player
  2. {
  3.     private:
  4.        double highscore;
  5.        string name;
  6.     public:
  7.        //write class methods here
  8. };
  9.  
Start here. Learn how to write a class. When that's working, create your Player objects and put them in a C++ Standard Library Container. My guess is that you will want to use a vector.

This should get you going. I don't want to code the whole thing for you.
Jun 7 '07 #3
Moezzie
17
yeah, i just whant a basic idea about how to do it.
That helps alot.
Thanks.
Jun 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sarah | last post by:
Hello! Does anybody know a script for a puzzle with Highscore? Many thanks before, Sarah
3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
30
by: MaxLindquist | last post by:
Hi! I want to make a highscore for a game i am making. How might i do that? Thanks
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: zuuperman | last post by:
Hi folks I have a little problem converting from an access database to the SQL server I need to have a highscore that shows the top 10 scores, grouped by email. In my access db i had this...
21
by: cromoglic | last post by:
Hello! I have been making a "guess what number the computer thinks of"-game in python (text-only) for educational reasons. Now, i want to implement a highscore in the code, which writes the best...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.