Skip to content

Instantly share code, notes, and snippets.

@sofhiasouza
Created September 20, 2019 13:53
Show Gist options
  • Save sofhiasouza/9d46f931366fbf330cf38404252b5d28 to your computer and use it in GitHub Desktop.
Save sofhiasouza/9d46f931366fbf330cf38404252b5d28 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, cont = 0;
cin >> n >> m;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= m ; j++)
{
int a;
cin >> a;
if(a) cont++; //se existe um livro nessa posição, somo mais um na minha variável contadora
}
}
cout << cont/n << "\n"; //divido a quantidade de livros total pela quantidade de estantes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment