hi everyone,
i have a problem in converting the c++ language to c language.
can anyone help me to do this because i just learn programming.
#include <stdio.h>
void choosePlay(char);
void playGame(int,int,int,int);
void match(int[][4]);
int r1,r2,c1,c2;
char comma;
int cards[4][4]={{1,3,2,4},{4,2,3,1},{5,7,6,8},{8,6,7,5}};
void main()
{
char click;
char newcard;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
cout<<"@ @\n";
cout<<"@ ## ## #### ## ## #### #### # # @\n";
cout<<"@ # # # # # # # # # # # # # # # @\n";
cout<<"@ # # # ### # # # # # #### ### @\n";
cout<<"@ # # # # # # # # # # @\n";
cout<<"@ # # #### # # #### # # ### @\n";
cout<<"@ @\n";
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n";
choosePlay(click);
do{
playGame(r1,c1,r2,c2);
match(cards);
cout<<"any card does not open?((Y)es or (N)o)";
cin>>newcard;
}while(newcard =='Y');
//this pushes the next board onto a blank screen
for (int b=0; b<=5; b++){
cout<<endl;
}
cout<<"YOU ARE THE WINNER!!"<<endl;
getch();
}
//----------------------------------------------------------------------------//
void choosePlay(char c){
cout<<"WELCOME TO MEMORY GAME"<<endl;
cout<<"DO YOU WANT TO PLAY THIS GAME?\n"<<endl;
cout<<"(y/n)\n\n";
cin>>c;
if(c=='y'){
//display board
cout<<"\n\n 1 2 3 4\n"<<endl;
cout<<" ";
for (int i=0; i<=6; i++)
{
cout<<" -";
}
cout<<endl;
for (int r=0; r<4; r++)
{
cout<<r+1<<" | ";
for (int c=0; c<4; c++)
{
cout<<" * ";
}
cout<<endl;
}
cout<<endl;
}
else if(c=='n') {
cout<<"Thank you for enter this game"<<endl;
}
}
//-----------------------------------------------------------------------------//
void playGame(int s1,int d1,int s2,int d2){
//selection
cout<<"Please insert the first card row and column seperated by a comma.\n";
cin>>s1>>comma>>d1;
cout<<"Please insert the second card row and column seperated by a comma.\n";
cin>>s2>>comma>>d2;
//fix
s1--;
d1--;
s2--;
d2--;
cout<<s2<<d2;
//reveal
cout<<"\n\n 1 2 3 4\n";
cout<<" ";
for (int i=0; i<=6; i++)
{
cout<<" -";
}
cout<<endl;
for (int r=0; r<4; r++)
{
cout<<r+1<<" | ";
for (int c=0; c<4; c++)
{
if ((r==s1)&&(c==d1))
{
cout<<" ";
}
else if((r==s2)&&(c==d2))
{
cout<<" ";
}
else
{
cout<<" * ";
}
}
cout<<endl;
}
}
//----------------------------------------------------------------------------//
void match(int cards[4][4]){
//match?
if (cards[r1][c1]==cards[r2][c2])
{
cout<<" ";
}
else
{
}
}
all your cooperation is appreciated.
kindly,
rossie.