game of guessing 3 nu,bers in their order from 10 to 20 within 10 trie

i have the code but it's written from 1 to 6 and i need it to be f

Page 1 of 1

1 Replies - 1034 Views - Last Post: 17 December 2008 - 06:12 AM Rate Topic: -----

#1 kooks   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-December 08

game of guessing 3 nu,bers in their order from 10 to 20 within 10 trie

Post icon  Posted 17 December 2008 - 03:44 AM

// game of guessing 3 numbers from 10 to 20 in their orer with 10 chances " master mind"

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>

void unique(int&,int&,int&);				   // function prototype
void guessednum(int,int,int,int,int,int);	 //function prototype
int order (int,int,int,int,int,int);		  //function prototype

int main()								   //starting function main
{
	int a, b, c;							  // declaring entered 
guessed numbers
	srand(time(0));						   // using time equation for random values of x1 x2 x3
int x1= 1+ rand() %6;
int x2= 1+ rand() %6;
int x3= 1+ rand() %6;
unique(x1,x2,x3);						// calling function unique

cout<<" enter 3 numbers between 1 and 6: "<< endl;  // tells the user to enter 3 numbers

for (int i = 1; i <= 10; i++)			   // loop 10 times to give 10 guessing chances by most
cout<< "try "<<i<<": ";			  // names the number of the try
cin>>a>>b>>c;						// prompt the user to enter 3 numbers

guessednum(a, b, c, x1, x2, x3);	 //calling function guessednum
cout<<" and "<<order(a, b, c, x1, x2, x3)<<" are in order\n";  // calling order an pronting how much

if(order(a, b, c, x1, x2, x3) ==3);	// condition for winning 3 numbers guessed in order
{
cout<<" ***you win*** "<<endl;	 // printing the winning statement

break;							// braking the loop after winning

							  
}
if(i == 10);		   // in case of reaching 10 cases without complete correct guessing
cout<<"***you lose***"<<endl;	 // informing the loss
			

return 0;

 }							  // end of function main


void unique(int&x1, int&x2,int&x3);	 // function definition to insure numbers uniqueness
 {

while (x2==x1)					// while loop to assign ifferent values in case of coincidence of x1,x2,x3
x2= 1+ rand() %6;
while ((x3==x1) || (x3==x2))
x3= 1+ rand() %6;
cout<<x1<<" "<<x2<<" "<<x3<<endl;
{
void guessednum (int a, int b, int c, int x1, int x2, int x3);  //function definition telling how much numbers guessed
	 {
int j=0;
if (a == x1 || b == x1 || c == x1)
j++;
if (a == x2 || b == x2 || c == x2)
j++;
if (a == x3 || b == x3 || c == x3)
j++;

cout << j << "guessed" << endl;		// counting how many numbers guessed

}

int order (int a, int b, int c, int x1, int x2, int x3);// function efinition concerning order of numbers
{
int i= 0;
if ( a == x1)
i++;

if ( b == x2)
i++;

if ( c == x3)
i++;
return i;
} // end of order



***added code tags***
--jjsaw5

Is This A Good Question/Topic? 0
  • +

Replies To: game of guessing 3 nu,bers in their order from 10 to 20 within 10 trie

#2 jjsaw5   User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: game of guessing 3 nu,bers in their order from 10 to 20 within 10 trie

Posted 17 December 2008 - 06:12 AM

Please make another post and give us more detail about what is going on.



:code:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1