22
1.cpp
22
1.cpp
@@ -8,34 +8,33 @@
|
||||
#include <windows.h>
|
||||
using namespace std;
|
||||
|
||||
// test input
|
||||
int try_num(string b)
|
||||
{
|
||||
int bb;
|
||||
try
|
||||
{
|
||||
bb = stoi(b);
|
||||
bb = stoi(b); //try int
|
||||
}
|
||||
catch (invalid_argument)
|
||||
catch (invalid_argument) // catch invaild input
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
string cardname[21];
|
||||
int score[7];
|
||||
string cardname[21];
|
||||
int score[7];
|
||||
//define cardname
|
||||
|
||||
array<int, 21> calculate(int arr[40])
|
||||
{
|
||||
array<int, 21> cal;
|
||||
fill(cal.begin(), cal.end(), 0);
|
||||
fill(cal.begin(), cal.end(), 0); // initilize
|
||||
for (int j = 0; j < 40; j++)
|
||||
{
|
||||
if (arr[j] == -1)
|
||||
continue;
|
||||
else
|
||||
cal[arr[j]]++;
|
||||
if (arr[j] == -1) continue; // pass blank
|
||||
else cal[arr[j]]++;
|
||||
}
|
||||
return cal;
|
||||
}
|
||||
@@ -57,6 +56,7 @@ void display_p(int arr[][40], int num)
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
//display players' cards
|
||||
|
||||
void display_s(int arr2[][3], int flag[5], int num)
|
||||
{
|
||||
@@ -65,6 +65,7 @@ void display_s(int arr2[][3], int flag[5], int num)
|
||||
cout << "Stack " << i + 1 << ": ";
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
// show color by ANSI code
|
||||
if (arr2[i][j] == 1)
|
||||
cout << " \033[31m red \033[0m";
|
||||
else if (arr2[i][j] == 2)
|
||||
@@ -85,10 +86,11 @@ void display_s(int arr2[][3], int flag[5], int num)
|
||||
cout << " +2_point ";
|
||||
}
|
||||
if (flag[i] == 2)
|
||||
cout << "(taken)";
|
||||
cout << "(taken)"; // mark taken cards
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
//dispaly stack
|
||||
|
||||
void getcard(int deck[76], bool vis[76], int stack[5][3], int flag_s[5], int pynum, int& counter, int cp_chk)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user