#include <iostream>using namespace std; int main() { int n,l,k=0; cin>>n; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { cin>>l; if(l==1) { k++; } } } cout<<k/2; return 0;}
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
3
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!