hi,
i have a problem to change this C++ code language to C language... - #include <iostream>
-
#include <conio.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
-
{
-
}
-
}
i hope someone can help me to change it...
thanks for your cooperation :)
2 1490
just replace all console i/o operators with corresponding printf and scanf.
Hey I rewrote and fix all the problems:
there is still some problem with the logic in if conditions. If you have any question write me back i will gladly assist you =). - #include <stdio.h>
-
#include <conio.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}};
-
int main()
-
{
-
-
char click;
-
char newcard;
-
-
-
-
-
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
-
printf("@ @\n");
-
printf("@ ## ## #### ## ## #### #### # # @\n");
-
printf("@ # # # # # # # # # # # # # # # @\n");
-
printf("@ # # # ### # # # # # #### ### @\n");
-
printf("@ # # # # # # # # # # @\n");
-
printf("@ # # #### # # #### # # ### @\n");
-
printf("@ @\n");
-
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
-
-
-
choosePlay(click);
-
-
do{
-
playGame(r1,c1,r2,c2);
-
match(cards);
-
-
printf("any card does not open?((Y)es or (N)o)");
-
scanf("%c",&newcard);
-
-
}while(newcard =='Y');
-
-
//this pushes the next board onto a blank screen
-
int b=0; //cannot be in for loop cannot be created
-
for (b=0; b<=5; b++){
-
printf("\n"); //replace endl with \n for newline
-
}
-
-
printf("YOU ARE THE WINNER!!\n");
-
getch();
-
}
-
-
//----------------------------------------------------------------------------//
-
-
void choosePlay(char c){
-
-
-
printf("WELCOME TO MEMORY GAME\n");
-
printf("DO YOU WANT TO PLAY THIS GAME?\n\n"); //place 2 newline dint know if that is what you wanted
-
printf("(y/n)\n\n");
-
scanf("%c",&c);
-
-
if(c=='y'){
-
//display board
-
printf("\n\n 1 2 3 4\n\n");
-
printf(" ");
-
int i=0;
-
for (i=0; i<=6; i++)
-
{
-
printf(" -");
-
}
-
printf("\n");
-
int r=0;
-
for (r=0; r<4; r++)
-
{
-
printf("%d \"| '",r+1);
-
int c=0;
-
for (c=0; c<4; c++)
-
{
-
printf(" * ");
-
}
-
printf("\n");
-
}
-
printf("\n");
-
}
-
else if(c=='n') {
-
printf("Thank you for entering this game ");
-
-
}
-
}
-
-
-
//-----------------------------------------------------------------------------//
-
-
void playGame(int s1,int d1,int s2,int d2){
-
-
-
//selection
-
printf("Please insert the first card row and column seperated by a comma.\n");
-
scanf("%d",&s1);
-
scanf("%d",&d1);
-
-
printf("Please insert the second card row and column seperated by a comma.\n");
-
-
scanf("%d",&s2);
-
scanf("%d",&d2);
-
-
//fix
-
s1--;
-
d1--;
-
s2--;
-
d2--;
-
printf("%d %d",s2,d2);
-
-
//reveal
-
printf("\n\n 1 2 3 4\n");
-
printf(" ");
-
int i=0;
-
for (i=0; i<=6; i++)
-
{
-
printf(" -");
-
}
-
printf("\n");
-
int r=0;
-
for (r=0; r<4; r++)
-
{
-
printf("%d | ",r+1);
-
int c=0;
-
for (c=0; c<4; c++)
-
{
-
if ((r==s1)&&(c==d1))
-
{
-
printf(" ");
-
}
-
else if((r==s2)&&(c==d2))
-
{
-
printf(" ");
-
-
}
-
else
-
{
-
printf(" * ");
-
}
-
}
-
printf("\n");
-
}
-
}
-
-
//----------------------------------------------------------------------------//
-
-
void match(int cards[4][4]){
-
-
//match?
-
-
if (cards[r1][c1]==cards[r2][c2])
-
{
-
printf(" ");
-
}
-
else
-
{
-
}
-
-
//label if you want to start again
-
//cls will clear screen and pause
-
//system("pause");
-
//system("cls");
-
//main(); call again if you want to start or write do-while to start the entire process
-
-
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant...
|
by: Al Bahr |
last post by:
H
I need to combine Ink strokes with the background image into a bit map. Would appreciate any help
Thank
A
|
by: Paulers |
last post by:
Hello,
I need to emulate keyboard strokes from a console application. The
console application monitors a textfile and when something is matched
in a text file I need the matched string outputted...
|
by: sreenulanka |
last post by:
I have five panel each one layout is set to gridbag layout.and also i have one main panel, layout is box layout.all components add to container.my page is larger than screen.it is not moving with...
|
by: cheezylu |
last post by:
I'm working on a site where my client will be able to maintain some of the text on the site using input boxes and such driven by PHP and MySQL. The problem I am running into is making it easy for...
|
by: abcd |
last post by:
Is there a way to capture key strokes on a system using python (other
than pyHook)? can wxPython capture keystrokes for the system (not
just, say a text box)?
thanks
|
by: =?Utf-8?B?QWxleGFuZGVy?= |
last post by:
Hi! I am new to C#. I read two C# books in the last two days which only
covered the basics. And now I am on my third day. The books were really bad,
because they did not cover windows applications,...
|
by: shadyabhi |
last post by:
How can i accept key strokes like Ctrl+A etc etc ... i mean combination of 2 keys... Pls give a small peice of code to demonstrate...
i use gcc under linux platform
|
by: kiksu |
last post by:
Hi,
I have problem,that I have to change programming language from C++ to C, but i don't get how to make these strokes work in C language!
There is the following strokes, what I need to change:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |