Hello, I'm a beginner and new to this forum. I'm really confused and stuck with a certain codes. I'm creating a memory word game and really confused on the arrays that takes word. I'm using printf, scanf, etc now because it is the one I required in comfortably use. I still don't know a lot about c++ cin, cout, etc.
Is it possible to have a program something like this?
like array = {cat,dog,rat}
/*inputted*/
cat /*\n*/
dog /*\n*/
rat /*\n*/
YOU GOT 15 POINTS!
Now, I'm really confused how to code and recognize that the output array = inputted array. I tried a similar case like this, but still not right, when i enter a word. it only recognize one word. And in addition, I dont know how to conver the cin and cout there to printf or something so i can removre the #include<iostream>.
P.S. this is just raw code and really thankful for those who can help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <time.h>
#define p printf
using namespace std;
void wait(int sec);
int main()
{
const int a = 3;
string word[a] = { "apple", "ball", "cat" };
string nword[a] = { "apple", "ball", "cat" };
string j;
int point;
int s = 0;
int ctr = 0;
p("BASIC");
for (int i = 0; i < a; i++)
{
cout << nword[i] << endl;/*don't know how to convert this to C*/
}
int seconds = 3;
wait(seconds);
system("CLS");
for (int i = 0; i < a; i++)
{
p("ENTER");
cin >> j; /*don't know how to convert this to C*/
int seconds = 5;
wait(seconds);
system("CLS");
if (j == word[i])
{
p("==========Congratulation=========");
p("==========You Have Score:");
p("%d Point", i + i);
}
else
{
p("Wrong");
}
}
return 0;
}
void wait(int sec)
{
clock_t end_wait;
end_wait = clock() + sec * CLK_TCK;
while (clock() < end_wait) {}
}
|