123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- #include <iostream>
- #include <math.h>
- using namespace std;
- int say(char l[255])
- {
- cout<<"0123456789012345"<<endl;
- for (int i=0;i<211;i=i+15)
- {
- cout<<(i/15+1)%10;
- for (int j=i+1;j<i+16;j++)
- {
- cout<<l[j];
- }
- cout<<endl;
- }
- }
- int judge(char a[225],int k,int b,char c)
- {
- if (a[k+1*b]==c&&a[k+2*b]==c&&a[k+3*b]==c&&a[k+4*b]==c)
- {
- return 1;
- cout<<a[k]<<' '<<k<<' '<<b<<' '<<c<<endl;
- }
- }
- int main () {
- char a[255];
- char c;
- int x,y,k,m,n;
- m=0;
- for (int i = 0; i < 226; i++)
- {
- a[i]=' ';
- }
- while (m==0)
- {
- cout<<"blck:";
- n=0;
- while(n==0)
- {
- cin>>x>>y;
- cout<<endl;
- k=(y-1)*15+x;
- if (a[k]==' ')
- {
- a[k]='X';
- n=1;
- }
- else cout<<"nope"<<endl;
- }
- say(a);
- c='X';
- for (int i=5; i<12; i++)
- {
- for(int j=0 ; j<15; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,1,c)==1||judge(a,k,-1,c)==1)
- {
- cout<<"black win!1"<<endl;
- m=1;
- }
- }
-
- }
- }
- for (int i=1; i<16; i++)
- {
- for(int j=4 ; j<11; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,15,c)==1||judge(a,k,-15,c)==1)
- {
- cout<<"black win!2"<<endl;
- m=1;
- }
- }
-
- }
- }
- for (int i=5; i<12; i++)
- {
- for(int j=4 ; j<11; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,14,c)==1||judge(a,k,-14,c)==1||judge(a,k,16,c)==1||judge(a,k,-16,c)==1)
- {
- cout<<"black win!3"<<endl;
- m=1;
- }
- }
-
- }
- }
- if (m==1)
- {
- break;
- }
- cout<<"white:";
- n=0;
- while(n==0)
- {
- cin>>x>>y;
- cout<<endl;
- k=(y-1)*15+x;
- if (a[k]==' ')
- {
- a[k]='O';
- n=1;
- }
- else cout<<"nope"<<endl;
- }
- say(a);
- c='O';
- for (int i=5; i<12; i++)
- {
- for(int j=0 ; j<15; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,1,c)==1||judge(a,k,-1,c)==1)
- {
- cout<<"white win!1"<<endl;
- m=1;
- }
- }
-
- }
- }
- for (int i=1; i<16; i++)
- {
- for(int j=4 ; j<11; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,15,c)==1||judge(a,k,-15,c)==1)
- {
- cout<<"white win!2"<<endl;
- m=1;
- }
- }
-
- }
- }
- for (int i=5; i<12; i++)
- {
- for(int j=4 ; j<11; j++)
- {
- k=j*15+i;
- if(a[k]==c)
- {
- if(judge(a,k,14,c)==1||judge(a,k,-14,c)==1||judge(a,k,16,c)==1||judge(a,k,-16,c)==1)
- {
- cout<<"white win!3"<<endl;
- m=1;
- }
- }
-
- }
- }
- }
- system("pause");
- return 0;
- }
|