Skip to content

Instantly share code, notes, and snippets.

@fenske
Created December 4, 2019 19:02
Show Gist options
  • Select an option

  • Save fenske/0c5dc17ee02ea89b90ecf0eb631c49ca to your computer and use it in GitHub Desktop.

Select an option

Save fenske/0c5dc17ee02ea89b90ecf0eb631c49ca to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
#define N 4
void f(int A[N][N], int B[N]);
int main() {
int A[N][N] = {
{1, 2, 3, 4},
{1, 2, 3, 4},
{1, 2, 3, 4},
{0, 2, 0, 4}
};
int B[N] = {1, 1, 1, 1};
f(A, B);
for (int i = 0; i < N; i++) {
cout << B[i] << " ";
}
}
void f(int A[N][N], int B[N]) {
for (int j = 0; j < N; j++) {
for (int i = 0; i < N; i++) {
if (A[i][j] == 0) {
B[j] = 0;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment