【发布时间】:2016-03-03 14:45:00
【问题描述】:
刚接触编程并试图了解数组和结构。我似乎遇到了数组问题,并且不确定我这样做是否正确。
namespace ConsoleApplication1
{
public struct MatrixVariables
{
public int x, y;
public MatrixVariables (int lowerV, int upperV)
{
x = lowerV;
y = upperV;
}
}
class Program
{
static void Main(string[] args)
{
int[,] a = new int[,] { { 0, 1, 1, 0 },{0,0,1,0}, {1,0,1,1}, {1,1,1,1}, {1,0,0,1} };
int[,] t = new int[,] { { 30, 10, 50, 25, 14 } };
MatrixVariables upperV = new MatrixVariables();
MatrixVariables lowerV = new MatrixVariables();
int maxP = 6;
int maxV = 6;
int p = 0;
int v = 0;
for (p=0;p<maxP;p++)
{
for (v=0; v == maxV;v++)
{
if (a[p,v] ==1)
{
if (upperV[v] > t[p])
{
upperV[v] = t[p];
}
}
}
}
}
}
}
【问题讨论】:
-
你期望索引器做什么?
-
有什么问题?你还没有列出一个
-
@BugFinder:错误信息在标题中,虽然帖子肯定会更清楚。