//Как-то громоздко получилось, но я так вижу. Эх, выходные. const n=5; var a:array[1..n] of integer; b:array[0..8] of integer; ar:array[1..n] of integer; i,c,j:integer; begin randomize; writeln('Array:'); for i:=1 to n do begin a[i]:=random(8); write(a[i]:4); end; for i:=1 to n do begin; for j:=0 to 8 do if a[i]=j then inc(b[j]); end; for i:=1 to n do begin; for j:=0 to 8 do if (b[j]>1) and (a[i]=j) then a[i]:=9; if a[i]<>9 then begin; inc(c); ar[c]:=a[i]; end; end; writeln; for i:=0 to 8 do writeln(i,'=',b[i]); writeln; writeln('Final array:'); for i:=1 to n do if a[i]=9 then a[i]:=0;
for i:=1 to c do begin; a[i]:=ar[i]; write(a[i]:4); end; end.
uses crt; var a, b, c, n, i, j :integer; s :array [1..10000] of integer; begin clrscr; writeln ('Vvedite razmer masiva'); read (n); writeln ('Vvedite chislo X'); read (a); for i:=1 to n do begin writeln ('Vvedit s[', i, '] element'); read (s[i]); end; for i:=1 to n do for j:=1 to n-1 do if s[j]<s[j+1] then begin b:=s[j]; s[j]:=s[j+1]; s[j+1]:=b; end; for i:=1 to n do begin write (s[i], ' '); if s[i]=a then inc (c); end; writeln; if c>0 then writeln ('3adanoe chislo prisytstvyet') else writeln('3adanoe chislo otsytstvyet'); end.
const n=5;
var a:array[1..n] of integer;
b:array[0..8] of integer;
ar:array[1..n] of integer;
i,c,j:integer;
begin
randomize;
writeln('Array:');
for i:=1 to n do
begin
a[i]:=random(8);
write(a[i]:4);
end;
for i:=1 to n do
begin;
for j:=0 to 8 do
if a[i]=j then inc(b[j]);
end;
for i:=1 to n do
begin;
for j:=0 to 8 do
if (b[j]>1) and (a[i]=j) then a[i]:=9;
if a[i]<>9 then
begin;
inc(c);
ar[c]:=a[i];
end;
end;
writeln;
for i:=0 to 8 do writeln(i,'=',b[i]);
writeln;
writeln('Final array:');
for i:=1 to n do
if a[i]=9 then a[i]:=0;
for i:=1 to c do
begin;
a[i]:=ar[i];
write(a[i]:4);
end;
end.
var a, b, c, n, i, j :integer;
s :array [1..10000] of integer;
begin
clrscr;
writeln ('Vvedite razmer masiva');
read (n);
writeln ('Vvedite chislo X');
read (a);
for i:=1 to n do
begin
writeln ('Vvedit s[', i, '] element');
read (s[i]);
end;
for i:=1 to n do
for j:=1 to n-1 do
if s[j]<s[j+1] then
begin
b:=s[j];
s[j]:=s[j+1];
s[j+1]:=b;
end;
for i:=1 to n do
begin
write (s[i], ' ');
if s[i]=a then inc (c);
end;
writeln;
if c>0 then writeln ('3adanoe chislo prisytstvyet') else writeln('3adanoe chislo otsytstvyet');
end.
P.S. Надеюсь на благодарность и лучший ответ.