解题思路:
注意事项:
参考代码:
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stdio.h> using namespace std; int main(void) { int n; int a[25][25]; vector<int> ans; cin >> n; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { cin >> a[i][j]; } } for(int i = 1; i <= n; i++) { int flag = 0; int j; for(j = 1; j <= n; j++) { if(a[i][j] == 1 && i != j) { if(a[j][i] == 1) flag =1; else break; } } if(flag && j > n) ans.push_back(i); } sort(ans.begin(), ans.end()); for(vector<int>::iterator it = ans.begin(); it != ans.end(); it++) { cout << *it << " "; } return 0; }
0.0分
2 人评分