Professional Documents
Culture Documents
RISK CPP
RISK CPP
#include<cstdlib>
#include<ctime>
using namespace std;
void boardPrint(){
for(int r=1;r<=30;r++){
for(int c=1;c<=30;c++){
}
// if( r==2 && c== 2 )
// cout<<"A";
else
cout<<" ";
}
cout<<endl;
}
}
int rollDice(){
return rand()%6+1;
}
int numOfPlayers(){
int numofplayers;
cout<<"Enter the number of players "<<endl;
cin>>numofplayers;
while(numofplayers>4 || numofplayers<=1 ){
cout<<"Enter number of players with in range of 2 to 4 "<<endl;
cin>>numofplayers;
}
return numofplayers;
}
void rollDiceForPlayers(int players){
for(int i=1;i<=players;i++){
cout<<"Dice number for player "<<i<<" is "<<rand()%6+1<<endl;
}
}
int main(){
srand(time(0));
boardPrint();
int numofplayers=numOfPlayers();
rollDiceForPlayers(numofplayers);