Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int a[n][n],b[n],sum=0;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- cin >> a[i][j];
- b[i] = 0;
- }
- for(int i = 0; i < n;i++)
- {
- for(int j = 0; j < n;j++)
- {
- if(a[i][j] != 0 && a[j][i] != 0)
- b[i]++;
- if(a[i][j] != 0 && a[j][i] == 0)
- {
- b[i]++;
- b[j]++;
- }
- }
- }
- for(int i = 0; i < n; i++)
- {
- if(b[i] < 2)
- b[i] = 0;
- sum+=b[i];
- }
- cout << sum << "\n";
- for(int i = 0; i < n; i++)
- cout << b[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement