✔ 最佳答案
What is the size of the array? Assuming it's one-dimension.
int result = 100;
for (int ii=0; ii < a.length; ii++)
{
result -= a[ii];
if (result < 0) { return result; }
}
if it's 2 dimension, you need to wrap it with another loop.
Find the size of the 1st dimension and 2nd dimension.
int result = 100;
for (int ii=0; ii < SIZE1; ii++)
{
for (int jj=0; jj < SIZE2; jj++)
{
result -= a[ii][jj];
if (result < 0) { return result; }
}
}