wuzi(1)(1).cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //我是个傻逼
  2. #include<iostream>
  3. //我是个傻逼
  4. #include<math.h>
  5. using namespace std;
  6. char a[255];
  7. void say(){//没有返回值得改成void
  8. cout<<"0123456789012345"<<endl;
  9. for(int i=0;i<211;i=i+15){
  10. cout<<(i/15+1)%10;
  11. for(int j=i+1;j<i+16;j++){
  12. cout<<a[j];
  13. }
  14. cout<<endl;
  15. }
  16. }
  17. int x,y,k,m,n;
  18. bool judge(int b,char c,int l1,int r1,int l2,int r2){
  19. for(int i=l1;i<r1;i++){
  20. for(int j=l2;j<r2;j++){
  21. k=j*15+i;
  22. if(a[k]==c&&a[k+1*b]==c&&a[k+2*b]==c&&a[k+3*b]==c&&a[k+4*b]==c){
  23. return true;
  24. cout<<a[k]<<' '<<k<<' '<<b<<' '<<c<<endl;
  25. }
  26. }
  27. }
  28. return false;//不写这行很危险
  29. }
  30. bool work(char c,string side){
  31. say();
  32. if(judge(1,c,5,12,0,15)||judge(-1,c,5,12,0,15)){
  33. cout<<side+" win!1"<<endl;
  34. return false;
  35. }
  36. if(judge(15,c,1,16,4,11)||judge(-15,c,1,16,4,11)){
  37. cout<<side+" win!2"<<endl;
  38. return false;
  39. }
  40. 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)){
  41. cout<<side+" win!3"<<endl;
  42. return false;
  43. }
  44. return true;
  45. }
  46. int main(){
  47. char c;
  48. for(int i=0;i<226;i++){
  49. a[i]=' ';
  50. }
  51. while(true){
  52. cout<<"black:";
  53. while(cin>>x>>y){
  54. cout<<endl;
  55. k=(y-1)*15+x;
  56. if(a[k]==' '){
  57. a[k]='X';
  58. break;
  59. }
  60. else cout<<"nope"<<endl;
  61. }
  62. if(!work('X',"black"))break;
  63. cout<<"white:";
  64. while(cin>>x>>y){
  65. cout<<endl;
  66. k=(y-1)*15+x;
  67. if(a[k]==' '){
  68. a[k]='O';
  69. break;
  70. }
  71. else cout<<"nope"<<endl;
  72. }
  73. if(!work('O',"white"))break;
  74. }
  75. system("pause");
  76. return 0;
  77. }