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

Pages: 1-

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 16:06



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;

^^^^^^^^^^^^^
fail.

>
and incase of trolls
Yes I am reading SICP.
also, we are NOT trolling when we say READ SICP.

Name: Anonymous 2007-12-11 16:08

The ones that repeatedly spam READ SICP READ SICP. tend to be.

Why fail?

I thought I had to show them in main too? it gave me errors when I didn't do that. or do I use "int d6();" in main?

I know nothing.

The path to Satori is long. :(

Name: Anonymous 2007-12-11 16:10

>>3 I posted too soon.
I'm a dumbass, self confessed. it works now :).

Thanks for pointing that out.

Name: Anonymous 2007-12-11 16:23

>>4
next time consult SICP.

Name: Anonymous 2007-12-11 16:25

>>5
DONT HELP HIM!

Name: Anonymous 2007-12-11 16:28

>>6
I am fond of the ``DONT HELP HIM!'' meme.

Name: Anonymous 2007-12-11 16:34

>>7
DONT HELP HIM!

Name: Anonymous 2007-12-11 16:55

Your compiler should have warned you that you were using uninitialised variables.

Name: Anonymous 2007-12-11 17:01

>>7
Actually, I did.

Name: g++ 2007-12-11 18:15

>>9
Actually, I did.

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.

Name: Anonymous 2007-12-11 22:32

ITT proof C++ rots the brain.
Seriously, how the fuck can you not realise the difference between declaring an int and having a function that returns an int?

>>12
Look up how cin works.

Name: Anonymous 2007-12-11 23:36

Name: Anonymous 2007-12-11 23:46

This is the worst thread I've ever read in my life.

Name: Anonymous 2007-12-11 23:54

>>10
>>11

What?

>>7

Actually, I invented that meme.

Name: Anonymous 2007-12-12 1:20

>>16

Actually, I did

Name: Anonymous 2011-02-03 1:51

Name: Anonymous 2011-02-04 14:21

Name: Anonymous 2011-02-04 17:34

Name: Anonymous 2011-02-17 20:06

dubz

Name: Anonymous 2013-01-19 23:41

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

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