Код | const tab:Char=Char(9); var B,C: array [1..40] of Integer; i,max_ind,temp: Integer; D: array[1..41] of Integer; begin ///////////Gen random array//////////// Randomize; for i:=1 to 40 do B[i]:=Round(Random(300))-150; ////////////////find max element////////////////// temp:=B[1]; max_ind:=1; for i:=2 to 40 do if temp>B[i] then begin temp:=B[i]; max_ind:=i; end; ///////////create new array without max/////// i:=1; while i<>max_ind do begin C[i]:=B[i]; i:=i+1; end; while i<>39 do begin C[i]:=B[i+1]; i:=i+1; end; /////////////create new array with insert 1//// i:=1; while i<>max_ind do begin D[i]:=B[i]; i:=i+1; end; i:=i+1; D[i]:=1; while i<>41 do begin D[i]:=B[i-1]; i:=i+1; end; //////writeln answer Writeln('Ishod massiv'); for i:=1 to 40 do begin Write(B[i]); write(tab); end; Writeln(' '); Writeln('bez max massiv'); for i:=1 to 39 do begin Write(C[i]); write(tab); end; Writeln(' '); Writeln('with 1 massiv'); for i:=1 to 41 do begin Write(D[i]); write(tab); end; Writeln(' '); Readln; end.
|
|