#include #include #include #include using namespace std; int main(){ int num[10][10]={0};//记录卡牌数字 int temp;//随机数 int flag[10]={0}; int ix,iy,ia,ib; int arr[10][10]={0}; int sum=0; cout << "记忆卡牌游戏规则" << endl; cout << "现有16张数字卡牌,由数字1~8组成,每个数字只出现2次" << endl; cout << "游戏者需要将卡牌翻至背面,找出所有相同的数字" << endl; cout << "每一轮只允许翻两张卡牌" << endl; cout << "如果卡牌数字相同,则将卡牌上有数字的一面显示出来" << endl; cout << "否则将卡牌翻回正面,进行下一轮" << endl; cout << "系统测量游戏者找出所有相同数字的卡牌所花费的步数(即进行多少轮)" << endl; system("pause"); srand(time(0)); for(int j=1;j<=4;j++){ for(int k=1;k<=4;k++){ while(true){ temp=rand()%8+1; if(flag[temp]<2){ num[j][k]=temp; flag[temp]++; break; } else{ continue; } } } } for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ cout <<"*"<<" "; } cout <>ix>>iy; arr[ix][iy]++; system("cls"); for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ if(arr[i][j]!=0){ cout <>ia>>ib; arr[ia][ib]++; system("cls"); for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ if(arr[i][j]!=0){ cout <