Advertisement
STANAANDREY

21/1/2020 II

Jan 21st, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int a[100][100], n, m, d[100];
  5.  
  6. void citire(int& n, int&  m, int a[][100])
  7. {
  8.     cin >> n >> m;
  9.     for (int i = 0; i < n; i++)
  10.         for (int j = 0; j < m; j++)
  11.             cin >> a[i][j];
  12. }
  13.  
  14. int nrnule(int n, int m, int a[][100],int i)
  15. {
  16.     int k = 0;
  17.     for (int j = 0; j < m; j++)
  18.         if (!a[i][j])
  19.             k++;
  20.     return k;
  21. }
  22.  
  23. void calcul(int n, int m, int a[][100])
  24. {
  25.     for (int i = 0; i < n; i++)
  26.         d[i] = nrnule(n, m, a, i);
  27. }
  28.  
  29. int main()
  30. {
  31.     citire(n, m, a);
  32.     calcul(n, m, a);
  33.     int maxi = d[0];
  34.     for (int i = 0; i < m; i++)
  35.         if (d[i] > maxi)
  36.             maxi = d[i];
  37.     for (int i = 0; i < n; i++)
  38.         if (d[i] == maxi)
  39.         cout << i << ' ';
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement