fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,l,k=0;
  6. cin>>n;
  7. for(int i=0;i<n;i++)
  8. {
  9. for(int j=0;j<n;j++)
  10. {
  11. cin>>l;
  12. if(l==1)
  13. {
  14. k++;
  15. }
  16. }
  17. }
  18. cout<<k/2;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5456KB
stdin
5
0 1 0 0 0 
1 0 1 1 0 
0 1 0 0 0 
0 1 0 0 0 
0 0 0 0 0 
stdout
3