You are viewing a single comment's thread. Return to all comments →
IS This Wrong ? ** **I calculated first all sides area and then substrating accordingli ?
int surfaceArea(int A_rows, int A_columns, int** A) { int area =6*A_rows*A_columns; int min = A_rows < A_columns ? A_rows : A_columns; for (int i =0; i<A_rows;i++) { for (int j =0; j<A_columns;j++){ area -= min - A[i][j]; } } for (int i =0;i<A_columns;i++) { area -= min - A[0][i]; } for (int i =0;i<A_columns;i++) { area -= min - A[A_rows-1][i]; } for (int i =0;i<A_rows;i++) { area -= min - A[i][0]; } for (int i =0;i<A_rows;i++) { area -= min - A[i][A_columns-1]; } for (int i =0; i<A_rows;i++) { for (int j=0; j<A_columns;j++) { area = area + min - A[0][0] + min - A[A_rows-1][A_columns-1] + min- A[0][A_columns-1] + min - A[A_rows-1][0]; } } if(A_columns == 1 && A_rows == 1 ) { return area; } return area-1; }
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 →
IS This Wrong ? ** **I calculated first all sides area and then substrating accordingli ?