![]() |
| | #1 |
| Registered User Join Date: Mar 2009
Posts: 16
| Help With Functions and Random Numbers Code: #include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int Dice (int dice1, int dice2)
{
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
dice1 = rand() % (5 + 1)+1;
dice2 = rand() % (5 + 1)+1;
return (dice1, dice2);
}
int rules()
{
system("cls");
cout << " The Rules Are Quite Simple. We Roll Two Dice.\n -If Even, Player 1 Gets a Point\n If Odd, Player 2 Gets a Point\n";
system("Pause");
int main ();
}
int game()
{
int times;
system("cls");
cout << "How Many Times Would You Like to Roll?";
cin >> times;
int Dice (int dice1, int dice2);
int main ();
}
int main()
{
int key;
cout << "Menu\n Press 1 for Rules\n Press Any Key to Play\n" ;
cin >> key;
if (key==1)
{rules();}
else
{game();}
int dice1;
int dice2 ;
cout << "First Dice = " << dice1 << endl;
cout << "Second Dice = " << dice2 << endl;
system("pause");
}
|
| CaliJoe is offline | |
| | #2 | |
| Registered User Join Date: Oct 2008
Posts: 98
| Quote:
As for looping... a do/while loop should be sufficient. If you don't understand most of what I said you may want to read your book over again... or look up information on looping and variable scope. | |
| Sparrowhawk is offline | |
![]() |
| Tags |
| code, function, random |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Random Numbers | JamesG89 | C++ Programming | 4 | 04-13-2007 03:00 PM |
| Will we ever have truly random numbers? | jalnewbie | C Programming | 7 | 11-30-2006 02:14 PM |
| Random Numbers | punter | C++ Programming | 8 | 11-04-2006 06:06 PM |
| Criteria based random numbers | alkisclio | C++ Programming | 6 | 09-14-2006 12:29 PM |
| time Delays and Random functions | markphaser | C++ Programming | 17 | 02-20-2006 07:10 PM |