题目
在一个机房中,服务器的位置标识在 n*m 的整数矩阵网格中,1 表示单元格上有服务器,0 表示没有。如果两台服务器位于同一行或者同一列中紧邻的位置,则认为它们之间可以组成一个局域网。
请你统计机房中最大的局域网包含的服务器个数。
输入描述
第一行输入两个正整数,n和m,0<n,m<=100
之后为n*m的二维数组,代表服务器信息
输出描述
最大局域网包含的服务器个数。
用例
| 输入 | 2 2 1 0 1 1 |
| 输出 | 3 |
| 说明 | [0][0]、[1][0]、[1][1]三台服务器相互连接,可以组成局域网 |
#include <stdio.h>
#include <map>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
class CNetServer
{
public:
unsigned int m_uiX;
unsigned int m_uiY;
int m_ArryServer[100][100];
int m_iMaxServer;
CNetServer(int iX,int iY,void* pBuff)
:m_uiX(iX),m_uiY(iY)
{
m_iMaxServer = 0;
memset(m_ArryServer,0x00,100*100*sizeof(int));
if (pBuff != 0)

最低0.47元/天 解锁文章
6545

被折叠的 条评论
为什么被折叠?



