Skip to content

Commit 78b9cff

Browse files
authored
matrix[1..row][1..column] 0으로 바꾸는 반복문 1개로 합침.
1 parent ac96dc7 commit 78b9cff

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

set-matrix-zeroes/yeonguchoe.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,9 @@ void setZeroes(int** matrix, int matrixSize, int* matrixColSize) {
2929
}
3030
}
3131

32-
for (int i = 1; i < column_size; i++) {
33-
if (matrix[0][i] == 0) {
34-
for (int j = 1; j < row_size; j++) {
35-
matrix[j][i] = 0;
36-
}
37-
}
38-
}
39-
4032
for (int i = 1; i < row_size; i++) {
41-
if (matrix[i][0] == 0) {
42-
for (int j = 1; j < column_size; j++) {
33+
for (int j = 1; j < column_size; j++) {
34+
if (matrix[0][j] == 0 || matrix[i][0] == 0) {
4335
matrix[i][j] = 0;
4436
}
4537
}

0 commit comments

Comments
 (0)