|
|
back to boardWhy is my answer wrong ? #include <iostream> using namespace std; void main() { int flag[100][100]; int flag1[100], N, j, flag2[100]; do { cin >> N; } while (N < 0 || N > 100);
for (int i = 1; i <= N; i++) { do { cin >> j; flag[i][j + 1] = 1; } while (j != 0); } flag1[1] = 1; for (int i = 1; i <= N; i++) { for (j = i + 1; j <= N; j++) { if (flag[i][j] == 1) { if (flag1[j] != 1 && flag1[j] != 2) { flag1[j] = 3 - flag1[i]; } } } } int i = 0; for (j = 1; j <= N; j++) { if (flag1[j] == 1) { flag2[i] = j; i++; } } for (j = 0; j < i; j++) { cout << flag1[i]; } } I have debugged, but finally I can't find why my code gives wrong answers. Anyone help me, plz. |
|
|