| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6256 人关注过本帖
标题:索引超出了数组界限。我把数组设的那么大,索引为什么会越界呢。到底哪里出 ...
取消只看楼主 加入收藏
云の翼
Rank: 1
等 级:新手上路
帖 子:17
专家分:3
注 册:2012-6-25
结帖率:87.5%
收藏
已结贴  问题点数:20 回复次数:0 
索引超出了数组界限。我把数组设的那么大,索引为什么会越界呢。到底哪里出错,初学者。谢谢!
  int [,]chengshi={{9,7,3,6,8,7,8,2,8,8},{5,6,5,9,6,5,6,1,8,6},{10,7,7,7,7,8,8,6,7,7},{9,9,8,6,10,10,8,5,9,7},{5,8,9,
                          5,6,7,10,7,7,10},{5,9,10,4,7,8,9,4,7,10},{4,8,7,3,4,5,6,7,5,7},{10,8,7,10,6,7,8,4,9,8},{6,8,7,6,6,
                           6,7,8,5,5},{4,7,8,8,7,9,8,3,6,9},{7,9,8,10,8,8,8,4,8,9}};
         public void fangfa()
        {
             //下面的十个track代表各个游标的对应的值
            int zhi1 = track1.Value;
            int zhi2 = track2.Value;
            int zhi3 = track3.Value;
            int zhi4 = track4.Value;
            int zhi5 = track5.Value;
            int zhi6 = track6.Value;
            int zhi7 = track7.Value;
            int zhi8 = track8.Value;
            int zhi9 = track9.Value;
            int zhi10 = track10.Value;
            int[] zhi = { zhi1, zhi2, zhi3, zhi4, zhi5, zhi6, zhi7, zhi8, zhi9, zhi10 };
            int[] chazhi = new int[20]; //10个指标对应的差值
            double[] pingfang = new double[20];//10个指标差值的平方
            double[] zuizhong = new double[1000];//1000个城市容量
            int i;
            for (i = 0; i < chengshi.Length; i++)
            {
                zuizhong[i] = 0;

                for (int j = 0; j < 10; j++)
                {
                    chazhi[j] = chengshi[i,j]- zhi[j];//提示出错:索引超出了数组界限。
                    pingfang[j] = Math.Pow(chazhi[j], 2);//各个差值的平方
                    zuizhong[i] = zuizhong[i] + pingfang[j];//指标总不至于比城市数量还多吧
                }
搜索更多相关主题的帖子: public 
2013-05-31 04:09
快速回复:索引超出了数组界限。我把数组设的那么大,索引为什么会越界呢。到底哪 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019689 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved