Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

help me /prog/

Name: Anonymous 2007-12-11 16:00

#include <iostream>
#include <cstdlib>
#include <time.h>

using namespace std;

int d6() { return rand()%6+1; }
int d8() { return rand()%8+1; }
int d10() { return rand()%10+1; }


int main()

{
      int d6;
      int d8;
      int d10;
      time_t sec;
      time(&sec);
      srand((int) sec);

     
      string xname;
      string yname;
      int xmhp;
      int ymhp;
      int xchp;
      int ychp;
      string junkdata;
     
     
      cout << "(At any point during this program, input any key to continue)" <<endl <<endl;
      cout << "Please enter a name for Player one: ";
      cin >> xname;
     
      cout << "Now enter a name for Player two: ";
      cin >> yname;
     
      cout << "\n" << "You have chosen the following names: " << xname << " and " << yname;
      cout << "\n" << "Now, three dice will be rolled, and this will be your health." <<endl;
        
         do {
               (xmhp = d10+d10+d10);
         } while (xmhp < 5);
     
      cout << "Your have rolled " << xmhp << " hit points" << "\n";
          
           xchp = xmhp;
          
           cout << xchp << "/" << xmhp << "\n";
           (xchp = xchp -d6);
           cout << xchp << "/" << xmhp << "\n";
           cout << "\n";
           (xchp = xchp -d6);
           cout << xchp << "/" << xmhp << "\n";
          
     
          
          
     
     
     
      system("PAUSE");
     
      return 0;
     
}

returns values of stupid amounts. not 30 or below.
however, I was told to do (xmhp = d10()+d10()+d10())
which failed. in epic ways.

Any help appreciated.

and incase of trolls
Yes I am reading SICP.

Name: Anonymous 2007-12-11 19:09

How does that shit even work? Wouldn't yname contain a new line since you didn't eat it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List