1. ## Memory Game!

Hi~~~ I am doing my computer project.......
this computer project is about "Memory Game"

this is following:

There are 20 cards. Each card has a number between 1- 10
each numbers occurs twice. Look at two cards,if they are the same, they are marked as taken. Game goes on until all cards are marked as taken

e.g of output:

"Enter two cards to be looked at:" // then user put 2 numbers

3,5

"card 3 has value of 7"
"card 5 has value of 6"

"Enter two cards to be looked at:"//user put 2 numbers again
3,6

"Both cards have value of 7,You found a pair!"

"Enter two cards to be looked at:"//user put 2 numbers again
3,4

"card 3 was already turned out!"

2. First, you need a structuce:
Code:
```struct Card
{
int number, value;
bool found;
};```
And initialization:

Code:
```Card deck[20];
for(int i = 0;  i < 20;  i++)
{
deck[i].found = 0;
deck[i].number = i;
if(i < 10)
deck[i].value = i+1;
else
deck[i].value = i+1-10;
}```
Perhaps a shuffle:

Code:
```Card temp;
int swap;
for(int i = 0;  i < 123;  i++)
{
temp = deck[rand()%20];
for(;;)
{
i = rand()%20;
if(i != swap.number)
break;
}
deck[temp.number] = deck[swap];
deck[swap] = temp;
}```
(write in a hurry - beware of errors!)

Now just flag the cards that have been found and compare the values to find a pair.

Code:
```get input to a and b
if((deck[a].value == deck[b].value) && (deck[a].found = 0))
{
Match found!
deck[a].found = deck[b].found = 1;
}```
And for a final check

Code:
```int i;
for(i = 0;  i < 20;  i++)
if(deck[i].found == 0)
break;
if(i == 19)
all cards found```