Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:01
Show Gist options
  • Save invatainfo/b65d8f559d7cea53b6f6c0eb9fbbb3cc to your computer and use it in GitHub Desktop.
Save invatainfo/b65d8f559d7cea53b6f6c0eb9fbbb3cc to your computer and use it in GitHub Desktop.
#include <fstream.h>
fstream f("matrice.in", ios::in);
fstream g("matrice.out", ios::out);
int n, m, a[100][100];
void citire() {
f >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
f >> a[i][j];
}
int produs(int j) {
int p = 1;
for (int i = 1; i <= n; i++)
if (a[i][j] == 0)
return 0;
else if (a[i][j] == 2)
p++;
return p;
}
void main() {
citire();
int max = 0;
for (int j = 1; j <= m; j++)
if (produs(j) > max)
max = produs(j);
for (j = 1; j <= m; j++)
if (produs(j) == max)
g << j << " ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment