2316: [C++一本通-广度优先搜索]1.面积

Memory Limit:128 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:495 Solved:251

Description

       编程计算由“1”号围成的下列图形的面积。面积计算方法是统计1号所围成的闭合曲线中点的数目。如图所示,在10*10的二维数组中,“1”围住了15个点,因此面积为15.

                                   0 0 0 0 0 0 0 0 0 0
                                   0 0 0 0 1 1 1 0 0 0
                                   0 0 0 0 1 0 0 1 0 0
                                   0 0 0 0 0 1 0 0 1 0
                                   0 0 1 0 0 0 1 0 1 0
                                   0 1 0 1 0 1 0 0 1 0
                                   0 1 0 0 1 1 0 1 1 0
                                   0 0 1 0 0 0 0 1 0 0
                                   0 0 0 1 1 1 1 1 0 0
                                   0 0 0 0 0 0 0 0 0 0

Input

一个由0和1组成的10*10的二维数组

Output

符号“1”围住的“0”的个数,即围成的面积

Sample Input Copy

0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 0 1 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0
0 0 1 0 0 0 1 0 1 0
0 1 0 1 0 1 0 0 1 0
0 1 0 0 1 1 0 1 1 0
0 0 1 0 0 0 0 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0

Sample Output Copy

15

HINT

加入题单

上一题 下一题 算法标签: