How about you give it a go on your own, and come back here to let us know exactly what parts you are having problems with. That way we aren't doing the homework for you and we know exactly what it is that you are having problems grasping or coding.
#include <iostream>
#include <cstdlib>
usingnamespace std;
void initial_fields(int field[][4]){
for (int i=0; i<4; i++)
{
for (int o=0; o<4; o++)
field[i][o]=(rand()%2);
}
}
void input_coord(int& x, int& y){
cout<<"insert your x coordinate(from 0 - 3): ";
cin>>x;
cout<<"insert your y coordinate (from 0 - 3): ";
cin>>y;
}
void checkin(int& x, int& y, int& counter, int field[][4]){
if(field[x][y]==1)
{
counter++;
cout<<"You have lost your life, you have: "<<3-counter<<"more";
cout<<"\n\n";
}
else
cout<<"You are doing well!"<<char(1)<<endl;
}
int main(){
int counter=0;
int x, y;
int field[4][4];
initial_fields(field);
do{
input_coord(x,y);
checkin(x,y,counter,field);
}while(counter<3);
cout<<"You lost all of your lives = GAME OVER!";
system("pause>0");
return 0;
}
Other than a few syntax error and lack of references theres nothing really wrong (other than the fact that you can't win).
The above example works fine.