|
|
вернуться в форумthis my code...please help me... wa#23... please gime some contrtests... VAR ok : BooLean; N, M : integer; B : Array [1 .. 100] of integer; A : Array [1 .. 100, 1 .. 100] of integer; PROCEDURE In_Data; Var i, W : integer; Begin ReadLn(N); ok := false; for i := 1 to N do begin Read(W); if W = 0 then begin ok := true; Exit; end; while W <> 0 do begin A[i, W] := 1; Read(W); end; ReadLn; end; End; PROCEDURE Out_Data; Var i : integer; Begin WriteLn(M); for i := 1 to N do if B[i] = 1 then Write(i, ' '); End; PROCEDURE Solve; Var i, j : integer; Begin for i := 1 to N do begin if B[i] = 0 then B[i] := 1; for j := 1 to N do if A[i, j] = 1 then begin if B[i] = 1 then B[j] := 2 else B[j] := 1; A[i, j] := 0; A[j, i] := 0; end; end; M := 0; for i := 1 to N do if B[i] = 1 then inc(M); End; PROCEDURE Run; Begin In_Data; if ok then begin WriteLn(0); Exit; end; Solve; Out_Data; End; BEGIN Run; END. |
|
|