var l,k:char; m,s:string; n,i,a:integer; begin read(s); l:=s[1]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; l:=s[2]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; l:=s[3]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; l:=s[4]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; l:=s[5]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; l:=s[6]; if ((ord(l)>223) and (ord(l)<256))or((ord(l)>96) and (ord(l)<122)) then begin a:=ord(l)-32;if a<>0 then begin k:=chr(a);if k<>'0' then m:=m+copy(k,1,1) end; end else begin if ord(l)=44 then n:=n+1; m:=m+l; end; writeln(m); writeln(n); end.
Например так(выводит начальный массив, максимальную сумму, измененный массив).
program test; uses crt; var arr:array[1..10] of integer; i,j,max,maxn:integer; begin randomize; clrscr; for i:=1 to 10 do begin arr[i]:=random(100); write(arr[i],' '); end; writeln;
max:=arr[1]+arr[2]; maxn:=2;
for i:=1 to 10 do for j:=1 to 10 do if i<>j then if max<arr[i]+arr[j] then begin max:=arr[i]+arr[j]; if i>j then maxn:=i else maxn:=j; end;
writeln('max summ=',max);
for i:=1 to 10 do begin if i<maxn then arr[i]:=0; write(arr[i],' '); end; readln; end.
program test;
uses crt;
var
arr:array[1..10] of integer;
i,j,max,maxn:integer;
begin
randomize;
clrscr;
for i:=1 to 10 do
begin
arr[i]:=random(100);
write(arr[i],' ');
end;
writeln;
max:=arr[1]+arr[2];
maxn:=2;
for i:=1 to 10 do
for j:=1 to 10 do
if i<>j then
if max<arr[i]+arr[j] then
begin
max:=arr[i]+arr[j];
if i>j then maxn:=i else maxn:=j;
end;
writeln('max summ=',max);
for i:=1 to 10 do
begin
if i<maxn then arr[i]:=0;
write(arr[i],' ');
end;
readln;
end.