You could do it in a switch, or actually series of switch statements, and then return the total value by keeping a running total.
Here I have done the first two for you. I leave it up to you to modify the rest.
Don't forget about order of operations when using parenthesis.
CODE
int total = 0;
// The following statement will evaluate to the following switch statement
// (x > 0 && y > 0 ? (estadoac[x - 1 + (y - 1) * this.cols] ? 1 : 0) : 0)
switch (estadoac[x - 1 + (y - 1) * this.cols])
{
case true:
switch (x > 0 && y > 0)
{
case true:
//Add one to total
total++;
break;
case false:
//Result is 0, so do not need to add to total
break;
}
break;
case false:
//Do not need to add anything to total as both results are 0
break;
}
// The following statement will evaluate to the following switch statement
// (y > 0 ? (estadoac[x + (y - 1) * this.cols] ? 1 : 0) : 0)
switch (estadoac[x + (y - 1) * this.cols])
{
case true:
switch (y > 0)
{
case true:
//Add one to total
total++;
break;
case false:
//Result is 0, so do not need to add to total
break;
}
break;
case false:
//Do not need to add anything to total as both results are 0
break;
}
}