Const n=10; var a,d:array[1..n] of integer; k,i,j,t:integer; begin Randomize; for i:=1 to n do begin a[i]:=random(900)+100; write(a[i]:4); end; writeln; writeln('Количество делителей:'); for i:=1 to n do begin k:=2; for j:=2 to a[i] div 2 do if a[i] mod j = 0 then k:=k+1; d[i]:=k; write(d[i]:4); end; writeln; for i:=1 to n-1 do for j:=1 to n-i do if d[j]>d[j+1] then begin t:=d[j]; d[j]:=d[j+1]; d[j+1]:=t; t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end; Writeln('Отсортированный массив:'); for i:=1 to n do Write(a[i],' '); Writeln end.
var a,d:array[1..n] of integer;
k,i,j,t:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=random(900)+100;
write(a[i]:4);
end;
writeln;
writeln('Количество делителей:');
for i:=1 to n do begin
k:=2;
for j:=2 to a[i] div 2 do
if a[i] mod j = 0 then k:=k+1;
d[i]:=k;
write(d[i]:4);
end;
writeln;
for i:=1 to n-1 do
for j:=1 to n-i do
if d[j]>d[j+1] then
begin
t:=d[j]; d[j]:=d[j+1]; d[j+1]:=t;
t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;
end;
Writeln('Отсортированный массив:');
for i:=1 to n do Write(a[i],' ');
Writeln
end.
Пример:
882 524 890 505 911 792 772 458 507 368
Количество делителей:
18 6 8 4 2 24 6 4 6 10
Отсортированный массив:
911 505 458 524 772 507 890 368 882 792
using namespace std;
int main()
{
int N,A,M;
double S = 0;
cout << "N = ", cin >> N, cout << "\n";
cout << "Vvedite N chisel:" << endl;
cin >> A;
M = A;
S+=A;
for(int i=2; i<=N; i++)
{
cin >> A;
if (A<M) M = A;
S+= A;
}
cout << "Srednee arifm. = " << S/N << "\n";
cout << "Min = " << M << "\n";
system("pause");
return 0;
}