Написать комментарий | |
06-06-2010 12:43 (ссылка)
Re: Pascal. Количество повторяющихся чисел в одномерном массиве.
zada4a prowe prostogo.. )))
ответить
(с цитатой)
06-06-2010 13:04 (ссылка)
Re: Pascal. Количество повторяющихся чисел в одномерном массиве.
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
const
n=10;
var
a : array [1..n] of integer;
i, t, j, c : integer;
ind : boolean;
begin
randomize;
for i:=1 to n do
a[i]:=random(n);
writeln('Massiv do');
for i:=1 to n do write(a[i]:3);
//-------------- sortirovka
repeat
ind:=true;
t:=a[1];
for i:=1 to n-1 do
if a[i]>a[i+1] then
begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
ind:=false;
end;
until ind;
//-------------- konez sortirovki
writeln;
writeln('Massiv posle');
for i:=1 to n do write(a[i]:3);
c:=0;
for i:=2 to n do
if a[i]=a[i-1] then inc(c);
writeln;
write('kolvo povtorov = ',c:3);
readln;
end.
{$APPTYPE CONSOLE}
uses
SysUtils;
const
n=10;
var
a : array [1..n] of integer;
i, t, j, c : integer;
ind : boolean;
begin
randomize;
for i:=1 to n do
a[i]:=random(n);
writeln('Massiv do');
for i:=1 to n do write(a[i]:3);
//-------------- sortirovka
repeat
ind:=true;
t:=a[1];
for i:=1 to n-1 do
if a[i]>a[i+1] then
begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
ind:=false;
end;
until ind;
//-------------- konez sortirovki
writeln;
writeln('Massiv posle');
for i:=1 to n do write(a[i]:3);
c:=0;
for i:=2 to n do
if a[i]=a[i-1] then inc(c);
writeln;
write('kolvo povtorov = ',c:3);
readln;
end.
Написать комментарий | ||