### 面试题

#### 程序详细代码：

#include <iostream>using namespace std;int len = 0;bool falg = true;int main(){  int pos[6][6] =   {-1,1,-1,1,-1,1,   1,-1,1,-1,1,-1,   -1,-1,-1,1,1,-1,   1,-1,-1,-1,-1,1,   1,1,-1,1,1,1,   1,-1,1,1,1,1  };  for(int c = 0; c < 6 ; c++)  {    for(int r=0; r < 6; r++)    {      if(pos[c][r] == 0)        continue;      //纵向棋子相同      if(pos[c][r] == pos[c][r+1])      {        if(r < 2)        {          for(int i = 1; i <= 4; i++ )          {            if(pos[c][r+i] == pos[c][r+i+1])              len++;            else            {              break;              len = 0;            }          }        }else        {          continue;        }        if(len >= 5)        {            if(pos[c][r] == 1)              cout << "黑子获胜！" << endl;            else if(pos[c][r] == -1)              cout << "白子获胜！" << endl;            return 0;        }      }      //横向棋子相同      if(pos[c][r] == pos[c+1][r])      {        if(c < 2)        {          for(int i = 1; i <= 4; i++ )        {          if(pos[c+i][r] == pos[c+i+1][r])            len++;          else          {            break;            len = 0;          }        }        }        else        {          continue;        }        if(len >= 5)        {            if(pos[c][r] == 1)              cout << "黑子获胜！" << endl;            else if(pos[c][r] == -1)              cout << "白子获胜！" << endl;            return 0;        }      }      //斜向下棋子相同      if(pos[c][r] == pos[c+1][r+1])      {        if(c < 2 && r < 2)        {          for(int i = 1; i <= 4; i++ )          {            if(pos[c+i][r+i] == pos[c+i+1][r+i+1])              len++;            else            {              break;              len = 0;            }          }        }        else        {          continue;        }        if(len >= 5)        {            if(pos[c][r] == 1)              cout << "黑子获胜！" << endl;            else if(pos[c][r] == -1)              cout << "白子获胜！" << endl;            return 0;        }      }      //斜向上棋子相同      if(pos[c][r] == pos[c+1][r-1])      {          if(r < 6 && r > 4 && c < 2)          {            for(int i = 1; i <= 4; i++ )            {              if(pos[c+i][r-i] == pos[c+i+1][r-i-1])                len++;              else              {                break;                len = 0;              }            }          }else          {            continue;          }          if(len >= 5)          {              if(pos[c][r] == 1)                cout << "黑子获胜！" << endl;              else if(pos[c][r] == -1)                cout << "白子获胜！" << endl;              return 0;          }        }    }  }}