(needs assistance)Mastermind calling functions and counting

Below is my code I am stuck right now in between my functions and I'm not sure how to count up how many are in the right place and how many of the number are right to tell them. Any and all help is greatly appreciated.


#include<iostream>
using namespace std;

void Intro()
//This introduces the player to the game once at the begining
{
cout<<"Welcome to Mastermind!"<<endl;
cout<<"I shall generate a secret arrangement of four numbers between 1 and 10."<<endl;
cout<<"You, oh code breaker shall try to guess my arrangement"<<endl;
cout<<"after you have guessed you shall recieve 2 pieces of information..."<<endl;
cout<<" 1: the number of pegs that are in the correct position"<<endl;
cout<<"2: the number of pegs that are the correct number but not in the correct position"<<endl;
cout<<"good luck on your quest oh code breaker"<<endl;
}

void Gen(int &rn1, int &rn2, int &rn3, int &rn4)
//This generates four random numbers from 1-10 individually using random
{
rn1= rand() % 10 + 1;
rn2= rand() % 10 + 1;
rn3= rand() % 10 + 1;
rn4= rand() % 10 + 1;

}
int pegone(int one)
//this stores the first number and compares if the number is in the right place
{
int ans1;
int count2=0;
cout<<"guess the first number"<<endl;
cin>>ans1;
if (one == ans1)
{
count2++;
}
return(ans1);
}

int pegtwo(int two)
//this stores the secong number
{
int ans2;
int count3 =0;
cout<<"guess the second number"<<endl;
cin>>ans2;
if (two == ans2)
{
count3++;
}
return(ans2);
}
int pegthree(int three)
//this stores the third number
{
int ans3;
int count4=0;
cout<<"guess the third number"<<endl;
cin>>ans3;
if (three ==ans3)
{
count4++;
}
return(ans3);
}
int pegfour(int four)
//this stores the fourth number
{
int ans4;
int count5=0;
cout<<"guess the fourth number"<<endl;
cin>>ans4;
if (four == ans4)
{
count5++;
}
return(ans4);
}

int main()
{
int num1, num2, num3, num4;
int ans;
cout<<"would you like to play? (yes=1 no=0) "<<endl;
cin>>ans;
if (ans==1)
{
Intro();
Gen(num1, num2, num3, num4);
pegone(num1);
pegtwo(num2);
pegthree(num3);
pegfour(num4);

}

return(0);
}
Topic archived. No new replies allowed.