Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Const M=1; N=16; G=5;
- Var P: array[M..N] of byte;
- Team: array[M..N] of string[20];
- X, s3 : string[20];
- i, j, L, R, K, s1,s2: integer;
- begin
- for i:=M to N do
- begin
- Team[i] := Char(64+i);
- P[i] := random(0,15)
- end;
- for i:=1 to G do
- begin
- s1:= random(1,N);
- s2:= random(1,N);
- s3:= Team[s1];
- Team[s1] := Team[s2];
- Team[s2] := s3;
- end;
- writeln('Перемешанный массив ',Team);
- for i:=1 to N-1 do
- for j:=1 to N-i do
- if Team[j][1] > Team[j+1][1] then begin
- s3 := Team[j];
- Team[j] := Team[j+1];
- Team[j+1] := s3;
- end;
- writeln('Отсортированный массив ',Team);
- Write ('Введите названия команды:'); Readln(X);
- L:=M; R:=N;
- while ((R-L)>0) do
- begin
- K:=(R+L) div 2;
- if (X=Team[K]) then begin R:=K; break; end;
- if (X<Team[K]) then R:=K else L:=K+1
- end;
- if (X=Team[R]) then Writeln(x,' имеет ', P[R],' очков')
- else Writeln(X,' нет такой команды');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement