Created
September 16, 2017 15:01
-
-
Save invatainfo/b65d8f559d7cea53b6f6c0eb9fbbb3cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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