1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //我是个傻逼
- #include<iostream>
- //我是个傻逼
- #include<math.h>
- using namespace std;
- char a[255];
- void say(){//没有返回值得改成void
- 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<<a[j];
- }
- cout<<endl;
- }
- }
- int x,y,k,m,n;
- bool judge(int b,char c,int l1,int r1,int l2,int r2){
- for(int i=l1;i<r1;i++){
- for(int j=l2;j<r2;j++){
- k=j*15+i;
- if(a[k]==c&&a[k+1*b]==c&&a[k+2*b]==c&&a[k+3*b]==c&&a[k+4*b]==c){
- return true;
- cout<<a[k]<<' '<<k<<' '<<b<<' '<<c<<endl;
- }
- }
- }
- return false;//不写这行很危险
- }
- bool work(char c,string side){
- say();
- if(judge(1,c,5,12,0,15)||judge(-1,c,5,12,0,15)){
- cout<<side+" win!1"<<endl;
- return false;
- }
- if(judge(15,c,1,16,4,11)||judge(-15,c,1,16,4,11)){
- cout<<side+" win!2"<<endl;
- return false;
- }
- if(judge(14,c,5,12,4,11)||judge(-14,c,5,12,4,11)||judge(16,c,5,12,4,11)||judge(-16,c,5,12,4,11)){
- cout<<side+" win!3"<<endl;
- return false;
- }
- return true;
- }
- int main(){
- char c;
- for(int i=0;i<226;i++){
- a[i]=' ';
- }
- while(true){
- cout<<"black:";
- while(cin>>x>>y){
- cout<<endl;
- k=(y-1)*15+x;
- if(a[k]==' '){
- a[k]='X';
- break;
- }
- else cout<<"nope"<<endl;
- }
- if(!work('X',"black"))break;
- cout<<"white:";
- while(cin>>x>>y){
- cout<<endl;
- k=(y-1)*15+x;
- if(a[k]==' '){
- a[k]='O';
- break;
- }
- else cout<<"nope"<<endl;
- }
- if(!work('O',"white"))break;
- }
- system("pause");
- return 0;
- }
|