Listing on Graph

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mr tux
    New Member
    • Sep 2007
    • 3

    #1

    Listing on Graph

    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
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by mr tux
    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)

    Comment

    • mr tux
      New Member
      • Sep 2007
      • 3

      #3
      [CODE=cpp]#include <iostream>
      #include <string>
      #include <ctime>
      using namespace std;

      int main ()
      {
      srand((unsigned )time(NULL));

      string player1,
      player2,
      player3;

      int die = 0,
      p1total = 0,
      p2total = 0,
      p3total = 0,
      round_count = 1,
      highest_total,
      count;



      cout << "Programed by Mark Hermes\n\n";

      cout << "The first person to roll a total of 20 wins.\n" <<
      "if more than two cross the 20 mark, then the one with the highest\n" <<
      "total wins.\n\n";
      cout << "Enter Player One's first name: ";
      cin >> player1;
      cout << "Enter Player Two's first name: ";
      cin >> player2;
      cout << "Enter Player Three's first name: ";
      cin >> player3;

      do
      {

      cout << "Round " << round_count ++ << endl;

      die = (rand() % 6) + 1;
      p1total = die + p1total;
      cout << player1 << " rolled " << die << " and their total is now " << p1total << endl;

      die = (rand() % 6) + 1;
      p2total = die + p2total;
      cout << player2 << " rolled " << die << " and their total is now " << p2total << endl;

      die = (rand() % 6) + 1;
      p3total = die + p3total;
      cout << player3 << " rolled " << die << " and their total is now " << p3total << endl
      << endl << endl;


      } while ((p1total < 20 ) && (p2total < 20) && (p3total < 20));


      // Three Way Tie--------------------------------------------------------------------
      if (( p1total >= 20 ) && ( p2total >= 20 ) && ( p3total >= 20 ))
      cout << "There is a three way tie between: " << player1 << " and " <<
      player2 << " and " << player3 << endl;

      // Two Way Ties---------------------------------------------------------------------
      if (( p1total >= 20 ) && ( p2total >= 20 ) && ( p3total < 20 ))
      cout << "There is a tie between: " << player1 << " and " << player2 << endl;

      if (( p1total >= 20 ) && ( p3total >= 20 ) && ( p2total < 20 ))
      cout << "There is a tie between: " << player1 << " and " << player3 << endl;

      if (( p2total >= 20 ) && ( p3total >= 20 ) && ( p1total < 20 ))
      cout << "There is a tie between: " << player2 << " and " << player3 << endl;

      // Single Player Wins---------------------------------------------------------------
      if (( p1total >= 20 ) && ( p2total < 20 ) && ( p3total < 20 ))
      cout << "The winner is: " << player1 << endl;

      if (( p2total >= 20 ) && ( p1total < 20 ) && ( p3total < 20 ))
      cout << "The winner is: " << player2 << endl;

      if (( p3total >= 20 ) && ( p1total < 20 ) && ( p2total < 20 ))
      cout << "The winner is: " << player3 << endl;
      }[/CODE]


      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
      Last edited by Ganon11; Sep 23 '07, 08:46 PM. Reason: Please use the [CODE] tags provided.

      Comment

      • Ganon11
        Recognized Expert Specialist
        • Oct 2006
        • 3651

        #4
        Vertically, as in:

        Code:
        Player 1   Player 2   Player 3
        X          X          X
        X          X          X
        X          X
        X          X
        X          X
        X
        X
        X
        ?

        Comment

        • mr tux
          New Member
          • Sep 2007
          • 3

          #5
          well names are on bottom but yes like that

          Comment

          • Ganon11
            Recognized Expert Specialist
            • Oct 2006
            • 3651

            #6
            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.

            Comment

            Working...