This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/ex5/ex5.cpp

140 lines
2.8 KiB
C++
Raw Normal View History

2021-10-21 16:13:46 +00:00
#include "vec.cpp"
#include "list.cpp"
#include <time.h>
#include <stdio.h>
2021-10-22 11:25:46 +00:00
std::string PU[54] = {
"1A", "1B", "1C", "1D",
"2A", "2B", "2C", "2D",
"3A", "3B", "3C", "3D",
"4A", "4B", "4C", "4D",
"5A", "5B", "5C", "5D",
"6A", "6B", "6C", "6D",
"7A", "7B", "7C", "7D",
"8A", "8B", "8C", "8D",
"9A", "9B", "9C", "9D",
"10A", "10B", "10C", "10D",
"JA", "JB", "JC", "JD",
"QA", "QB", "QC", "QD",
"KA", "KB", "KC", "KD",
"BlackJoker", "RadJoker"};
2021-10-21 16:13:46 +00:00
int main()
{
2021-10-22 11:25:46 +00:00
int xipai_flag = 0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
2021-10-21 16:13:46 +00:00
srand(time(NULL));
2021-10-22 11:25:46 +00:00
Vec v(54, 2);
2021-10-21 16:13:46 +00:00
v.printall();
List l;
printf("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
2021-10-22 11:25:46 +00:00
for (int i = 0; i <= 53; i++)
2021-10-21 16:13:46 +00:00
{
l.firstInsert(v.get(i));
2021-10-22 11:25:46 +00:00
std::cout << PU[l[0]];
printf("\n");
}
Begin:
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD>?(0/1)");
scanf("%d", &xipai_flag);
if (xipai_flag == 1)
{
v.reorder();
l.clear();
printf("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
for (int i = 0; i <= 53; i++)
{
l.firstInsert(v.get(i));
std::cout << PU[l[0]];
printf("\n");
}
xipai_flag == 0;
goto Begin;
}
printf("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
List p1, p2, p3;
for (int i = 0; i <= 53; i++)
{
switch (i % 3)
{
case 0:
p1.firstInsert(l[i]);
break;
case 1:
p2.firstInsert(l[i]);
break;
case 2:
p3.firstInsert(l[i]);
break;
}
}
l.clear();
// p1.sort();
// p2.sort();
// p3.sort();
int player = 0, opt = 0;
List *pai;
select:
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(1/2/3)");
scanf("%d", &player);
switch (player)
{
case 1:
pai = &p1;
break;
case 2:
pai = &p2;
break;
case 3:
pai = &p3;
break;
default:
printf("ʧ<EFBFBD><EFBFBD>\n");
goto select;
2021-10-21 16:13:46 +00:00
}
2021-10-22 11:25:46 +00:00
while (1)
{
printf("first:%d",(*pai).first()->data);
printf("1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>ƶ<EFBFBD>4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d", &opt);
switch (opt)
{
case 1:
for (int i = 0; i < (*pai).getSize(); i++)
{
printf("%d\n",(*pai).get(i));
}
break;
case 2:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d", &opt);
// l.firstInsert((*pai)[opt]);
(*pai).remove(opt);
printf("first6:%d",(*pai).first()->data);
printf("ʣ<EFBFBD><EFBFBD>%d \n",pai->getSize());
printf("%d",pai->get(0));
break;
case 3:
for (int i = 0; i <l.getSize(); i++)
{
std::cout << l[i];
printf("\n");
}
2021-10-21 16:13:46 +00:00
2021-10-22 11:25:46 +00:00
case 4:
goto select;
default:
printf("ʧ<EFBFBD><EFBFBD>\n");
}
}
2021-10-21 16:13:46 +00:00
return 0;
}