Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program lab1_2;
- {$APPTYPE CONSOLE}
- {$R *.res}
- Uses
- System.SysUtils;
- Type
- TPointer = ^TListElement;
- TListElement = Record
- Data: Integer;
- Lnext: TPointer;
- End;
- Function GetInt(Min, Max: Integer): Integer;
- Var
- IsCorrect: Boolean;
- N: Integer;
- Begin
- Repeat
- IsCorrect := True;
- Try
- Readln(N);
- Except
- IsCorrect := False;
- Writeln('Вы ввели некорректные данные. Попробуйте снова.');
- End;
- If IsCorrect And ((N > Max) Or (N < Min)) Then
- Begin
- IsCorrect := False;
- Writeln('Введено значение не входящее в диапазон допустимых значений');
- End;
- Until IsCorrect;
- GetInt := N;
- End;
- Procedure Make(N: Integer; Var First: TPointer);
- Var
- I: Integer;
- Temp: TPointer;
- Begin
- New(First);
- Temp := First;
- First^.Data := 1;
- New(First^.Lnext);
- First := First^.Lnext;
- For I := 2 To N Do
- Begin
- New(First^.Lnext);
- First^.Data := I;
- If (I = N) Then
- First^.Lnext := Temp
- Else
- First := First^.Lnext;
- End;
- End;
- Procedure OutExcel(N, K: Integer);
- Var
- Count: TPointer;
- I, Meter: Integer;
- Begin
- New(Count);
- Make(N, Count);
- Meter := 1;
- Write(N, ':', ' ');
- While (Count^.Lnext <> Count) Do
- Begin
- If (Meter = K) Then
- Begin
- Write(Count^.Lnext.Data, ' ');
- Count^.Lnext := Count^.Lnext^.Lnext;
- Meter := 0;
- End
- Else
- Count := Count^.Lnext;
- Inc(Meter);
- End;
- Write(' ', 'последним выйдет: ');
- Writeln(Count^.Data);
- End;
- Var
- I, K: Integer;
- Begin
- Write('Введите порядок удаления игроков : ');
- K := GetInt(1, 64);
- Writeln(1, ':', ' ', ' ', '|', 1);
- For I := 2 To 64 Do
- OutExcel(I, K);
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement