#include<cstdio>
#include<iostream>
#include<ctime>
#include<algorithm>
#include<windows.h>
using namespace std;/*
红色:1,2
黄色:3,4
蓝色:5,6
绿色:7,8
紫色:9
*/
int colour[3],num[3],ans,correct,aihard,you,ai;
void cun_dang(){
ai = 0;
aihard = 0;
you = 0;
}
void waiting(int x){
int endd;int staa = time(0);endd = staa;
while(endd - staa < 1) endd = time(0);
return;
}
void col(int a){
switch(a){
case 1:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);break;
case 3:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);break;
case 2:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);break;
case 4:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);break;
case 5:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);break;
default:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
}
}
void gc(){
while(true){
ans = 0;
// bool flag = false;
// cout<<1;
for(int i = 0;i <= 2;i++){
num[i] = rand() % 9 + 1;
colour[i] = rand() % 5 + 1;
// for(int j = 1;j < i;j++)
// if(colour[i] == colour[j] || num[i] == num[j]);
// flag = true;
// cout<<2;
// if(flag) break;
// cout<<100;
}
// if(flag) {/*cout << 4;*/continue;
// }
bool c[6] = {0,0,0,0,0,0},d[11] = {0,0,0,0,0,0,0,0,0,0,0};
bool flag = false;
for(int i = 0;i <= 2;i++){if(c[colour[i]]) flag = true;
else c[colour[i]] = true;
// if(c[num[i]]) flag = true;
// else c[num[i]] = true;
}
if(flag) continue;
bool b[11] = {0,0,0,0,0,0,0,0,0,0,0};int n = 0;
for(int i = 0;i <= 2;i++){
if(((num[i] + 1) / 2) == colour[i]){n++;ans = num[i];}
}
if(n == 1){if(rand() % 5 == 1){return;}else continue;
}
if(n > 1) continue;
for(int i = 0;i <= 2;i++){
b[colour[i] * 2 - 1] = b[colour[i] * 2] = b[num[i]] = true;
}
// cout << 3;
if(n) {/*cout << 5;*/continue;
}
for(int i = 1;i <= 9;i++) n += (1 - b[i]);
if(n != 1) {/*cout<<6*/;continue;
}
if(ans != 0) return;
for(int i = 1;i <= 9;i++)
if(!b[i]){
ans = i;
break;
}
if(ans == 9 && rand() % 3 != 0 && rand() % 4 != 3) continue;
return;
}
}
void game1(){
printf("原有物品:\n");
for(int i = 1;i <= 9;i++){
col((i + 1) / 2);
printf("%d ",i);
}
col(0);
gc();
while(num[1] == num[2] || num[2] == num[3] || num[3] == num[1] || colour[1] == colour[2] || colour[2] == colour[3] || colour[3] == colour[1])
gc();
printf("\n卡片:\n");
for(int i = 0;i <= 2;i++){
col(colour[i]);
printf("%d ",num[i]);
}
col(0);
int x;
cin >> x;
if(x == ans) printf("答对了!");
else printf("答错了。");
correct += (x == ans);
}
int main(){
srand(time(NULL));
// cun_dang();
// if(aihard == 0){
//
// }
// double www = time(0);
// cout << www;
int st = time(0);
for(int i = 1;i <= 11;i++) game1();
int ed = time(0);
double x = 100.0 * correct * correct *correct / 121 / (ed - st),y = 100.0 / 11.0 * correct; int z = ed - st;
printf("时间:%d\n正确率:%.1lf%\n优秀指数:%.3f",z,y,x);
return 0;
}