include #include #include #include #include #ifdef _WIN32 #include #else #include #endif using namespace std; void shuffle(string cardTyperr[], int n) {
#include <iostream>
#include <bits/stdc++.h>
#include <chrono>
#include <stdlib.h>
#include <cstdlib>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
void shuffle(string cardTyperr[], int n)
{
unsigned seed = chrono::system_clock::now().time_since_epoch().count();
shuffle(cardTyperr, cardTyperr + n, default_random_engine(seed));
for (int i = 0; i < n; ++i)
cout << cardTyperr[i] << " ";
cout << endl;
cout << flush;
system ("CLS");
}
void playerScore(string playerName[])
{
int player1 = 0;
int player2 = 0;
cout << "Score for PLAYER 1: " << player1 << endl;
cout << "Score for PLAYER 2: " << player2 << endl;
}
int main() {
string playerName[2] = {"PLAYER 1", "PLAYER 2"};
int cardOrder[8] = {0, 1, 2, 3, 4, 5, 6, 7};
for (int i = 0; i < 8; i++) {
cout << cardOrder[i] << " ";
}
cout << endl;
string cardType[8] = {"A", "A", "B", "B", "C", "C", "D", "D"};
for (int i = 0; i < 8; i++) {
cout << cardType[i] << " ";
}
cout << endl;
cout << " " << flush;
Sleep(2000);
system ("CLS");
int n = sizeof(cardType) / sizeof(cardType[0]);
shuffle(cardType, n);
for (int i = 0; i < 8; i++) {
cout << cardOrder[i] << " ";
}
cout << endl;
int cardOrderrrSize = *(&cardOrder + 1) - cardOrder;
while (cardOrderrrSize > 0) {
cout << "*" << " ";
cardOrderrrSize -= 1;
}
cout << endl;
playerScore(playerName);
return 0;
}
What modification should I do in the code above so it run task as mentioned below
2. Track 2 players playing in turn and record their scores.
3. When the cards are flipped in pairs, remove it from the position in display.
Step by step
Solved in 2 steps