Skip to content

Instantly share code, notes, and snippets.

@songpu2015617
Created April 6, 2015 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songpu2015617/46b8ba53f41adb40560a to your computer and use it in GitHub Desktop.
Save songpu2015617/46b8ba53f41adb40560a to your computer and use it in GitHub Desktop.
CC150 1.7
void zero(int **a, int m, int n){
bool row[m], col[n];
memset(row, false, sizeof(row));
memset(col, false, sizeof(col));
for(int i=0; i<m; ++i)
for(int j=0; j<n; ++j)
if(a[i][j] == 0){
row[i] = true;
col[j] = true;
}
for(int i=0; i<m; ++i)
for(int j=0; j<n; ++j)
if(row[i] || col[j])
a[i][j] = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment