|
|
вернуться в форумHelp me!!!!!!!!!!!!!! Послано BYF 9 ноя 2002 18:37 Program P1112; Type Coor=Record X,Y:Integer; End; Var N,I,J,Last,Which:Integer; Num,Del:Array[1..100] Of Coor; procedure Sort(l, r: longint); var i, j, x: longint; Y:Coor; begin i := l; j := r; x := Num[(l+r) DIV 2].Y; repeat while Num[i].Y < x do i := i + 1; while x < Num[j].Y do j := j - 1; if i <= j then begin y := Num[i]; Num[i] := Num[j]; Num[j] := y; i := i + 1; j := j - 1; end; until i > j; if l < j then Sort(l, j); if i < r then Sort(i, r); end; Begin Readln(N); For I:=1 To N Do Begin Readln(Num[I].X,Num[I].Y); If Num[I].X>Num[I].Y Then Begin J:=Num[I].X; Num[I].X:=Num[I].Y; Num[I].Y:=J; End; End; Sort(1,N); I:=0; Last:=0; Which:=0; Repeat Inc(I); If Num[I].X>=Last Then Begin Inc(Which); Last:=Num[I].Y; Del[Which]:=Num[I]; End; Until I=N; Writeln(Which); For I:=1 To Which Do Writeln(Del[I].X,' ',Del[I].Y); End. Sorry, I found I made a big mistake, and now I get AC!!! Послано BYF 9 ноя 2002 18:43 |
|
|