二维数组

扫码查看
本文介绍了二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨错了吗?
如果不是,为什么最后一行有错误?
错误:索引超出了数组的范围.

HiIs it wrong?
If not why is there an error in the last line?
error:Index was outside the bounds of the array.

const int n = 5;
        int[,] next=new int[n,n];

            for(int i=0;i<=n;i++)
                for (int j = 0; j <= n; j++)
                    next[i,j]= -1;

推荐答案

for(int i=0;i<=n;i++)
                for (int j = 0; j <= n; j++)


将是


will be

for(int i=0;i<n;i++)
                for (int j = 0; j < n; j++)



从0到5表示其取值为6倍.但是数组声明为最大大小为5.



For 0 to 5 means its taking value for 6 times .But array is declared with max size of 5.



这篇关于二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 17:14
查看更多