473,387 Members | 1,897 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,387 software developers and data experts.

Listing on Graph

3
i have a program due and i need to output a score, should look something like this:
x x
x x x
x x
x x x
A B C
i don't have any code so far but i'd put up my whole program if you guys need it. right now i'm just looking for something that will count a score and list it like above^^^ thanks
-mr tux
Sep 19 '07 #1
5 1169
sicarie
4,677 Expert Mod 4TB
i have a program due and i need to output a score, should look something like this:
x x
x x x
x x
x x x
A B C
i don't have any code so far but i'd put up my whole program if you guys need it. right now i'm just looking for something that will count a score and list it like above^^^ thanks
-mr tux
How do you get that score? Is it in a file, is it input through the command line? Gotten off a webpage? (Once you read it in, you can output it however you want)
Sep 21 '07 #2
mr tux
3
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8.     srand((unsigned)time(NULL));
  9.  
  10.     string    player1,
  11.             player2,
  12.             player3;    
  13.  
  14.     int die = 0,
  15.         p1total = 0,
  16.         p2total = 0,
  17.         p3total = 0,
  18.         round_count = 1,
  19.         highest_total,
  20.         count;
  21.  
  22.  
  23.  
  24.     cout << "Programed by Mark Hermes\n\n";
  25.  
  26.     cout << "The first person to roll a total of 20 wins.\n" <<
  27.             "if more than two cross the 20 mark, then the one with the highest\n" <<
  28.             "total wins.\n\n";
  29.     cout << "Enter Player One's first name: ";
  30.     cin >> player1;
  31.     cout << "Enter Player Two's first name: ";
  32.     cin >> player2;
  33.     cout << "Enter Player Three's first name: ";
  34.     cin >> player3;
  35.  
  36.     do
  37.     {
  38.  
  39.     cout << "Round " << round_count ++ << endl;
  40.  
  41.     die = (rand() % 6) + 1;
  42.     p1total = die + p1total;
  43.     cout << player1 << " rolled " << die << " and their total is now " << p1total << endl;
  44.  
  45.     die = (rand() % 6) + 1;
  46.     p2total = die + p2total;
  47.     cout << player2 << " rolled " << die << " and their total is now " << p2total << endl;
  48.  
  49.     die = (rand() % 6) + 1;
  50.     p3total = die + p3total;
  51.     cout << player3 << " rolled " << die << " and their total is now " << p3total << endl
  52.          << endl << endl;
  53.  
  54.  
  55.     } while ((p1total < 20 ) && (p2total < 20) && (p3total < 20));
  56.  
  57.  
  58. // Three Way Tie--------------------------------------------------------------------
  59.     if (( p1total >= 20 ) && ( p2total >= 20 ) && ( p3total >= 20 ))
  60.         cout << "There is a three way tie between: " << player1 << " and " <<
  61.         player2 << " and " << player3 << endl;
  62.  
  63. // Two Way Ties---------------------------------------------------------------------
  64.     if (( p1total >= 20 ) && ( p2total >= 20 ) && ( p3total < 20 ))
  65.         cout << "There is a tie between: " << player1 << " and " << player2 << endl;
  66.  
  67.     if (( p1total >= 20 ) && ( p3total >= 20 ) && ( p2total < 20 ))
  68.         cout << "There is a tie between: " << player1 << " and " << player3 << endl;
  69.  
  70.     if (( p2total >= 20 ) && ( p3total >= 20 ) && ( p1total < 20 ))
  71.         cout << "There is a tie between: " << player2 << " and " << player3 << endl;
  72.  
  73. // Single Player Wins---------------------------------------------------------------
  74.     if (( p1total >= 20 ) && ( p2total < 20 ) && ( p3total < 20 ))
  75.         cout << "The winner is: " << player1 << endl;
  76.  
  77.     if (( p2total >= 20 ) && ( p1total < 20 ) && ( p3total < 20 ))
  78.         cout << "The winner is: " << player2 << endl;
  79.  
  80.     if (( p3total >= 20 ) && ( p1total < 20 ) && ( p2total < 20 ))
  81.         cout << "The winner is: " << player3 << endl;
  82. }

i apologize if its too large for forums, don't know what your policy is, now what i need to do is display each persons score with an X so if you have 25 i need 25 x's vertically. i've attached a sample of what it should look like, i know i need a loop just don't know the format

: mr tux
Sep 23 '07 #3
Ganon11
3,652 Expert 2GB
Vertically, as in:

Expand|Select|Wrap|Line Numbers
  1. Player 1   Player 2   Player 3
  2. X          X          X
  3. X          X          X
  4. X          X
  5. X          X
  6. X          X
  7. X
  8. X
  9. X
?
Sep 23 '07 #4
mr tux
3
well names are on bottom but yes like that
Sep 23 '07 #5
Ganon11
3,652 Expert 2GB
You should just use a for... loop going from the max value to 1. If the player's score is equal to or greater than the index, print an X for them. All you have to worry about then is formatting it to make it look pretty - enough spaces, and all that.
Sep 23 '07 #6

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

Similar topics

9
by: Lilith | last post by:
Is there a python module somewhere (been searching today, no luck) which has efficiently coded various graph-handling routines, such as finding the shortest path through a graph, or the set of all...
25
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.)...
1
by: entropy123 | last post by:
Hey all, In an effort to solve a sticky - for me - problem I've picked up Sedgewick's 'Algorithm's in C'. I've tried working through the first few problems but am a little stumped when he refers...
2
by: MLH | last post by:
A97 Am having difficulty displaying graph in Form View that I see fine in graph control on form opened in design view. I know I'm doing something wrong. If I open the form in design view - I...
11
by: Andreas.Burman | last post by:
Hi What is the best way to implement a undirected weighted graph ADT in javascript?
0
by: mylog | last post by:
I have downloaded a GLEE(Graph Layout Execution Engine) and written the following code to display a windows form from a web page but i am encountering with a small problem on displaying the graph...
2
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
4
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; }...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
0
by: eureka2050 | last post by:
Hi all, I am creating a radar chart containing 2 plots using jpgraph. My code is as follows:- include ("./jpgraph/src/jpgraph.php"); include ("./jpgraph/src/jpgraph_radar.php"); //...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.