#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
#include<windows.h>
#include<string>
using namespace std;
int main(){
char i,k;
cout<<" ================"<<endl;
cout<<" =====三子棋====="<<endl;
cout<<" ================"<<endl<<endl;
cout<<"按n继续" <<endl;
while(1){
if (-32767 == GetAsyncKeyState('N')){
break;
}
}
system("cls");
cout<<"注意:黑先"<<endl;
cout<<"q|w|e"<<endl;
cout<<"-+-+-"<<endl;
cout<<"a|s|d"<<endl;
cout<<"-+-+-"<<endl;
cout<<"z|x|c"<<endl;
cout<<"按n开始游戏" <<endl;
while(1){
if (-32767 == GetAsyncKeyState('N')){
break;
}
}
while(1){
string q="无",w="无",e="无",a="无",s="无",d="无",z="无",x="无",c="无";
int q1=0,w1=0,e1=0,a1=0,s1=0,d1=0,z1=0,x1=0,c1=0;
int panduan=0,pd1=0;
bool num=false,flag1=1;
while(1){
system("cls");
cout<<q<<"|"<<w<<"|"<<e<<endl;
cout<<"--+--+--"<<endl;
cout<<a<<"|"<<s<<"|"<<d<<endl;
cout<<"--+--+--"<<endl;
cout<<z<<"|"<<x<<"|"<<c<<endl<<endl;
if(q=="黑"&&w=="黑"&&e=="黑"||q=="黑"&&s=="黑"&&c=="黑"||q=="黑"&&a=="黑"&&z=="黑"||w=="黑"&&s=="黑"&&x=="黑"||a=="黑"&&s=="黑"&&d=="黑"||e=="黑"&&d=="黑"&&c=="黑"||e=="黑"&&s=="黑"&&z=="黑"||z=="黑"&&x=="黑"&&c=="黑"&&pd1==0){
cout<<"黑棋胜!!!"<<endl;
pd1=1;
Sleep(1000);
}else if(q=="白"&&w=="白"&&e=="白"||q=="白"&&s=="白"&&c=="白"||q=="白"&&a=="白"&&z=="白"||w=="白"&&s=="白"&&x=="白"||a=="白"&&s=="白"&&d=="白"||e=="白"&&d=="白"&&c=="白"||e=="白"&&s=="白"&&z=="白"||z=="白"&&x=="白"&&c=="白"&&pd1==0){
cout<<"白棋胜!!!"<<endl;
pd1=1;
Sleep(1000);
}else if(q1==1&&w1==1&&e1==1&&a1==1&&s1==1&&d1==1&&z1==1&&x1==1&&c1==1&&pd1==0){
cout<<"平局"<<endl;
pd1=1;
Sleep(1000);
}
if(pd1==1){
cout<<"是否继续?(y/n)"<<endl;
while(1){
if (-32767 == GetAsyncKeyState('Y')){
cout<<"游戏准备开始!"<<endl<<endl;
Sleep(2000);
system("cls");
break;
}
if (-32767 == GetAsyncKeyState('N')){
return 0;
}
}
}
while(1){
if (-32767 == GetAsyncKeyState('Q')){
if(num==false){
q="黑";
num=true;
q1++;
}else{
q="白";
num=false;
q1++;
}
break;
}
if (-32767 == GetAsyncKeyState('W')){
if(num==false){
w="黑";
num=true;
w1++;
}else{
w="白";
num=false;
w1++;
}
break;
}
if (-32767 == GetAsyncKeyState('E')){
if(num==false){
e="黑";
num=true;
e1++;
}else{
e="白";
num=false;
e1++;
}
break;
}
if (-32767 == GetAsyncKeyState('A')){
if(num==false){
a="黑";
num=true;
a1++;
}else{
a="白";
num=false;
a1++;
}
break;
}
if (-32767 == GetAsyncKeyState('S')){
if(num==false){
s="黑";
num=true;
s1++;
}else{
s="白";
num=false;
s1++;
}
break;
}
if (-32767 == GetAsyncKeyState('D')){
if(num==false){
d="黑";
num=true;
d1++;
}else{
d="白";
num=false;
d1++;
}
break;
}
if (-32767 == GetAsyncKeyState('Z')){
if(num==false){
z="黑";
num=true;
z1++;
}else{
z="白";
num=false;
z1++;
}
break;
}
if (-32767 == GetAsyncKeyState('X')){
if(num==false){
x="黑";
num=true;
x1++;
}else{
x="白";
num=false;
x1++;
}
break;
}
if (-32767 == GetAsyncKeyState('C')){
if(num==false){
c="黑";
num=true;
c1++;
}else{
c="白";
num=false;
c1++;
}
break;
}
}
}
}
return 0;
}
#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
#include<windows.h>
#include<string>
using namespace std;
int main(){
char i,k;
cout<<" ================"<<endl;
cout<<" =====三子棋====="<<endl;
cout<<" ================"<<endl<<endl;
cout<<"按n继续" <<endl;
while(1){
if (-32767 == GetAsyncKeyState('N')){
break;
}
}
system("cls");
cout<<"注意:黑先"<<endl;
cout<<"q|w|e"<<endl;
cout<<"-+-+-"<<endl;
cout<<"a|s|d"<<endl;
cout<<"-+-+-"<<endl;
cout<<"z|x|c"<<endl;
cout<<"按n开始游戏" <<endl;
while(1){
if (-32767 == GetAsyncKeyState('N')){
break;
}
}
while(1){
string q="无",w="无",e="无",a="无",s="无",d="无",z="无",x="无",c="无";
int q1=0,w1=0,e1=0,a1=0,s1=0,d1=0,z1=0,x1=0,c1=0;
int panduan=0,pd1=0;
bool num=false,flag1=1;
while(1){
system("cls");
cout<<q<<"|"<<w<<"|"<<e<<endl;
cout<<"--+--+--"<<endl;
cout<<a<<"|"<<s<<"|"<<d<<endl;
cout<<"--+--+--"<<endl;
cout<<z<<"|"<<x<<"|"<<c<<endl<<endl;
if(q=="黑"&&w=="黑"&&e=="黑"||q=="黑"&&s=="黑"&&c=="黑"||q=="黑"&&a=="黑"&&z=="黑"||w=="黑"&&s=="黑"&&x=="黑"||a=="黑"&&s=="黑"&&d=="黑"||e=="黑"&&d=="黑"&&c=="黑"||e=="黑"&&s=="黑"&&z=="黑"||z=="黑"&&x=="黑"&&c=="黑"&&pd1==0){
cout<<"黑棋胜!!!"<<endl;
pd1=1;
Sleep(1000);
}else if(q=="白"&&w=="白"&&e=="白"||q=="白"&&s=="白"&&c=="白"||q=="白"&&a=="白"&&z=="白"||w=="白"&&s=="白"&&x=="白"||a=="白"&&s=="白"&&d=="白"||e=="白"&&d=="白"&&c=="白"||e=="白"&&s=="白"&&z=="白"||z=="白"&&x=="白"&&c=="白"&&pd1==0){
cout<<"白棋胜!!!"<<endl;
pd1=1;
Sleep(1000);
}else if(q1==1&&w1==1&&e1==1&&a1==1&&s1==1&&d1==1&&z1==1&&x1==1&&c1==1&&pd1==0){
cout<<"平局"<<endl;
pd1=1;
Sleep(1000);
}
if(pd1==1){
cout<<"是否继续?(y/n)"<<endl;
while(1){
if (-32767 == GetAsyncKeyState('Y')){
cout<<"游戏准备开始!"<<endl<<endl;
Sleep(2000);
system("cls");
break;
}
if (-32767 == GetAsyncKeyState('N')){
return 0;
}
}
}
while(1){
if (-32767 == GetAsyncKeyState('Q')){
if(num==false){
q="黑";
num=true;
q1++;
}else{
q="白";
num=false;
q1++;
}
break;
}
if (-32767 == GetAsyncKeyState('W')){
if(num==false){
w="黑";
num=true;
w1++;
}else{
w="白";
num=false;
w1++;
}
break;
}
if (-32767 == GetAsyncKeyState('E')){
if(num==false){
e="黑";
num=true;
e1++;
}else{
e="白";
num=false;
e1++;
}
break;
}
if (-32767 == GetAsyncKeyState('A')){
if(num==false){
a="黑";
num=true;
a1++;
}else{
a="白";
num=false;
a1++;
}
break;
}
if (-32767 == GetAsyncKeyState('S')){
if(num==false){
s="黑";
num=true;
s1++;
}else{
s="白";
num=false;
s1++;
}
break;
}
if (-32767 == GetAsyncKeyState('D')){
if(num==false){
d="黑";
num=true;
d1++;
}else{
d="白";
num=false;
d1++;
}
break;
}
if (-32767 == GetAsyncKeyState('Z')){
if(num==false){
z="黑";
num=true;
z1++;
}else{
z="白";
num=false;
z1++;
}
break;
}
if (-32767 == GetAsyncKeyState('X')){
if(num==false){
x="黑";
num=true;
x1++;
}else{
x="白";
num=false;
x1++;
}
break;
}
if (-32767 == GetAsyncKeyState('C')){
if(num==false){
c="黑";
num=true;
c1++;
}else{
c="白";
num=false;
c1++;
}
break;
}
}
}
}
return 0;
}