1 #include <bits/stdc++.h> 2 using namespace std; 3 int a[25][25]; 4 int main() { 5 int n; 6 cin >> n; 7 for (int i = 1; i <= n; i++) { 8 for (int j = 1; j <= n; j++) { 9 cin >> a[i][j]; 10 } 11 } 12 int len; 13 if (n % 2 == 0) { 14 len = n / 2; 15 } else { 16 len = n / 2 + 1; 17 } 18 for (int j = 1; j <= n; j++) { 19 int sum = 0; 20 for (int i = 1; i <= n; i++) { 21 if (a[i][j] == 1) { 22 sum++; 23 } 24 } 25 if (sum >= len) { 26 cout << j << " "; 27 } 28 } 29 return 0; 30 }
原文:https://www.cnblogs.com/fx1998/p/12807051.html