Const K = 13; Var A:array[1..K] of integer; i:integer; S:real; Begin Write('Исходный массив: '); For i:= 1 to K do Begin A[i]:=random(21)-10; Write(A[i],' '); End; WriteLn; {Первое задание:} For i:= 1 to K div 2 do S:=S+A[i]; WriteLn('S = ',S); {Второе задание:} S:=0; For i:= 1 to K do if i mod 2 = 0 then S:=S+A[i]; WriteLn('S = ',S); {Третье задание} S:=1; For i:= 1 to K do if i mod 2 <> 0 then S:=S*A[i]; WriteLn('S = ',S); {Четвёртое задание:} S:=0; For i:= 1 to K do if (A[i] mod 2 = 0)and(i mod 2 = 0) then S:=S+A[i]; WriteLn('S = ',S); End.
var s,s1:string; a:array[1..100] of string; n,i,j,k:byte; begin writeln('Введите текст из слов, разделенных пробелами'); readln(s); s:=' '+s+' '; n:=length(s); i:=2;k:=0;while i<=n do if (s[i]<>' ')and (s[i-1]=' ') then begin k:=k+1; j:=i; s1:=''; while (j<=n) and (s[j]<>' ') do begin s1:=s1+s[j]; j:=j+1; end; a[k]:=s1; i:=i+length(s1); end else i:=i+1; for i:=1 to k-1 do for j:=i+1 to k do if a[i]>a[j] then begin s1:=a[i]; a[i]:=a[j]; a[j]:=s1 end; writeln('Слова текста в алфавитном порядке:'); for i:=1 to k do writeln(a[i]); end.
2