毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

输入一个二维随机bool数组B[,],求出全部连通域 第2页

更新时间:2012-7-17:  来源:毕业论文
                                    {
                                        A[i, j] = A[i, j - 1];
                                        list[A[i, j] - 1].Add(new Point(i, j));
                                    }
                                }
                                else if (B[i - 1, j - 1])//判断左上
                                {
                                    if (A[i - 1, j - 1] != 0)//左上面有值,则此点与左上点连通
                                    {
                                        A[i, j] = A[i - 1, j - 1];
                                        list[A[i, j] - 1].Add(new Point(i, j));
                                    }
                                }
                                else if (B[i - 1, j])//判断上点
                                {
                                    if (A[i - 1, j] != 0)//上一点中已有值,则此点与上一点连通
                                    {
                                        A[i, j] = A[i - 1, j];
                                        list[A[i, j] - 1].Add(new Point(i, j));
                                    }
                                }
                                else//这是个新连通
                                {
                                    A[i, j] = list.Count + 1;
                                    list.Add(new List<Point> { new Point(i, j) });
                                }
                            }
                        }
                        else//在左边缘,只需判断上面的元素
                        {
                            if (i > 0)//不在左上角
                            {
                                if (B[i - 1, j])
                                {
                                    if (A[i - 1, j] != 0)//上一点中已有值,则此点与上一点连通
                                    {
                                        A[i, j] = A[i - 1, j];
                                        list[A[i, j] - 1].Add(new Point(i, j));
                                    }
                                    else//上一点没值,这是一个新的连通
                                    {
                                        A[i, j] = list.Count + 1;
                                        list.Add(new List<Point> { new Point(i, j) });
                                    }
                                }
                            }
                            else//在左上角
                            {
                                A[i, j] = list.Count + 1;
                                list.Add(new List<Point> { new Point(i, j) });
                            }
                        }
                    }
                }
            }

上一页  [1] [2] 

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。