It's not a huge thing.
I'm risking writing your program for you but I like a project so here's my stab.
Throw it into your compiler & it will work. I'm sure there's a more concise way of doing it but I just wrote this out and it does the trick if I know what you want and so there you go.
Code:
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int numDice=5;
int diceArray[5]={0,0,0,0,0};
bool same[5] = {0,0,0,0,0};
bool choice;
int RandomNumber(int iMin, int iMax)
{
return((rand() % (abs(iMax-iMin)+1))+iMin);
}
int RollDice()
{
return(RandomNumber(1,6));
}
int CheckForMatches()
{
int matches=0;
for(int i=0; i<numDice; i++)
if(same[i]) matches++;
return matches;
}
int main(int argc, char *argv[])
{
srand( (unsigned)time( NULL ) );
do
{
for(int i=0; i<numDice; i++)
if(!same[i]) diceArray[i]=RollDice();
for(int i=0; i<numDice; i++)
for(int j=0; j<numDice; j++)
if(diceArray[i] == diceArray[j] && i != j)
same[i]=true;
for(int i=0; i<numDice; i++)
{
if(same[i])
cout << " ";
cout << diceArray[i] << "\n";
}
cout << "\n\n\n";
if(CheckForMatches()<5)
{
if(!CheckForMatches())
cout << "There were no matches. Roll dice again?\n";
else
cout << "You got some matches! Roll remaining dice?\n";
cout << "1 - Yes\n0 - No\n\n";
}
else
cout << "They're all matched up! Enter 0 to quit.\n";
cin >> choice;
cout << "\n\n\n\n";
} while(choice);
return 0;
}
If you want me to explain anything just ask.
BTW arrays are tricky, I'm having some of my own problems with them (see thread).