You are viewing a single comment's thread. Return to all comments →
int baseArea = w * h ; int area = baseArea * 2 ; int lastWidthIndex = w-1 , lastHeightIndex = h-1 ; for(int i = 0 ; i < shape.length ; i++){ for(int j = 0 ; j < shape[i].length ; j++){ if(i == 0) area += shape[i][j] ; if(i == lastWidthIndex) area += shape[i][j] ; if(j == 0) area += shape[i][j] ; if(j == lastHeightIndex) area += shape[i][j] ; if(i != lastWidthIndex) area += Math.abs(shape[i][j] - shape[i+1][j]) ; if(j != lastHeightIndex) area += Math.abs(shape[i][j] - shape[i][j+1]) ; } }
} }
return area ;
Seems like cookies are disabled on this browser, please enable them to open this website
3D Surface Area
You are viewing a single comment's thread. Return to all comments →
Java
} }
return area ;