Advertisement
SergeyPGUTI

11.1

Apr 15th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.  
  10.     int n,cnt=0;
  11.     cin>>n;
  12.     int **a=new int*[n];
  13.     for (int i=0;i<n;i++)
  14.         a[i]=new int [n];
  15.     for (int i=0;i<n;i++)
  16.         for (int j=0;j<n;j++)
  17.         cin>>a[i][j];
  18.     for (int i=0;i<n;i++) // граф симметричный, считаем еденицы ниже главной диагонали
  19.         for (int j=0;j<i;j++)
  20.         if (a[i][j]==1) cnt++;
  21.     cout<<cnt;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement