这题不知道为什么,应该是找入度为0的点,但是总是WA,后来改找出度为最大的,AC了。
#include <iostream>
#include <cstring>
using namespace std;
int degree[1010];
char data[1010];
int main() {
int n;
int i;
int ans = 0;
while(cin >> n) {
memset(degree, 0, sizeof(degree));
for(i = 0; i < n; i++) {
cin >> data;
for(int j = 0; data[j] != '/0'; j++) {
if(data[j] == '1' && j != i) degree[i]++;
}
if(degree[i] > degree[ans]) ans = i;
}
cout << ans + 1 << endl;
}
return 0;
}