- 游戏
- 2025-04-10 13:33:12 @
#include <bits/stdc++.h>
using namespace std;
string s[4]={"Joker", "Queen", "King", "Ace"}, p1[6], p2[6];
bool b[20], p1b[6], p2b[6];//J0~1, Q2~7, K8~13, A14~19
int p1gun, p2gun, sum1, sum2;
int main()
{
srand(time(0));
p1gun=rand()%6;
p2gun=rand()%6;
while(1)
{
memset(b, false, sizeof(b));
memset(p1b, false, sizeof(p1b));
memset(p2b, false, sizeof(p2b));
sum1=sum2=5;
for(int i = 1; i<=5;)
{
int id = rand()%20;
if(!b[id])
{
b[id]=true;
if(id<=1)
{
p1[i]=s[0];
}
else if(id<=7)
{
p1[i]=s[1];
}
else if(id<=13)
{
p1[i]=s[2];
}
else
{
p1[i]=s[3];
}
i++;
}
}
for(int i = 1; i<=5;)
{
int id = rand()%20;
if(!b[id])
{
b[id]=true;
if(id<=1)
{
p2[i]=s[0];
}
else if(id<=7)
{
p2[i]=s[1];
}
else if(id<=13)
{
p2[i]=s[2];
}
else
{
p2[i]=s[3];
}
i++;
}
}
int id = rand()%2;
cout << "p" << id+1 << "first" << endl;
string table = s[rand()%3+1];
cout << table << "'s table" << endl;
string ss;
cin >> ss;
bool liar;
int len;
if(id==0)
{
for(int i = 1; i<=5; i++)
{
cout << p1[i] << " ";
}
cin >> len;
while(len>min(3, sum1) || len==0)
{
cout << "angin!!!" << endl;
cin >> len;
}
liar=false;
sum1-=len;
for(int i = 1; i<=len;)
{
int id;
cin >> id;
if(!p1b[id])
{
p1b[id]=true;
if(p1[id]!=table && p1[id]!=s[0])
{
liar=true;
}
i++;
}
else
{
cout << "angin!!!" << endl;
}
}
}
else
{
for(int i = 1; i<=5; i++)
{
cout << p2[i] << " ";
}
cin >> len;
while(len>min(3, sum2) || len==0)
{
cout << "angin!!!" << endl;
cin >> len;
}
liar=false;
sum2-=len;
for(int i = 1; i<=len;)
{
int id;
cin >> id;
if(!p2b[id])
{
p2b[id]=true;
if(p2[id]!=table && p2[id]!=s[0])
{
liar=true;
}
i++;
}
else
{
cout << "angin!!!" << endl;
}
}
}
while(1)
{
for(int i = 1; i<=100; i++)
{
cout << endl;
}
id=(id+1)%2;
cout << "p" << id+1 << "turn" << endl;
cout << "pre len is " << len << endl;
cin >> ss;
if(id==0)
{
for(int i = 1; i<=5; i++)
{
cout << p1[i] << " ";
}
cin >> len;
if(len==0 || sum2==0)
{
cout << liar << endl;
if(liar)
{
p2gun--;
if(p2gun==-1)
{
cout << "P1 win!!" << endl;
return 0;
}
break;
}
else
{
p1gun--;
if(p1gun==-1)
{
cout << "P2 win!!" << endl;
return 0;
}
break;
}
}
while(len>min(3, sum1))
{
cout << "angin!!!" << endl;
cin >> len;
}
liar=false;
sum1-=len;
for(int i = 1; i<=len;)
{
int id;
cin >> id;
if(!p1b[id])
{
p1b[id]=true;
if(p1[id]!=table && p1[id]!=s[0])
{
liar=true;
}
i++;
}
else
{
cout << "angin!!!" << endl;
}
}
}
else
{
for(int i = 1; i<=5; i++)
{
cout << p2[i] << " ";
}
cin >> len;
if(len==0 || sum1==0)
{
cout << liar << endl;
if(liar)
{
p1gun--;
if(p1gun==-1)
{
cout << "P2 win!!" << endl;
return 0;
}
break;
}
else
{
p2gun--;
if(p2gun==-1)
{
cout << "P1 win!!" << endl;
return 0;
}
break;
}
}
while(len>min(3, sum1))
{
cout << "angin!!!" << endl;
cin >> len;
}
liar=false;
sum2-=len;
for(int i = 1; i<=len;)
{
int id;
cin >> id;
if(!p2b[id])
{
p2b[id]=true;
if(p2[id]!=table && p2[id]!=s[0])
{
liar=true;
}
i++;
}
else
{
cout << "angin!!!" << endl;
}
}
}
}
}
return 0;
}
0 条评论
目前还没有评论...