Опишите что здесь происходит?
Private Sub OptionButton1_Click()
For i = 1 To 10000
Cells(i, 5) = ""
If Cells(i, 1) = "" Then
n = i - 1
Exit For
End If
Next i
For i = 2 To n
For j = i + 1 To n
If Cells(i, 4) < Cells(j, 4) Then
t = Cells(i, 1)
Cells(i, 1) = Cells(j, 1)
Cells(j, 1) = t
t1 = Cells(i, 2)
Cells(i, 2) = Cells(j, 2)
Cells(j, 2) = t1
t2 = Cells(i, 3)
Cells(i, 3) = Cells(j, 3)
Cells(j, 3) = t2
t3 = Cells(i, 4)
Cells(i, 4) = Cells(j, 4)
Cells(j, 4) = t3
End If
Next j
Next i
End Sub
N = 13;
Type
Mass = array[1..N] of real;
Var
f:file of real;
A:Mass;
Max:integer;
Procedure CF(f:file of real);
Begin
Assign(f,'File.real');
Rewrite(f);
For var i:= 1 to N do
Write(f,N*(random-random))
End;
Procedure RF(f:file of real; Var A:Mass; Var Max:integer);
Var
i:integer;
Begin
Reset(f);
Write('Исходный массив:');
Max:=1;
For i:= 1 to N do
Begin
Read(f,A[i]);
Write(' ',A[i]:0:3);
if A[i] > A[Max] then Max:=i;
End;
WriteLn;
End;
Begin
CF(f);
RF(f,A,Max);
WriteLn('Max = A[',Max,'] = ',A[Max]:0:3);
End.
Пример работы программы:
Исходный массив: 8.731 1.629 1.482 9.547 3.067 -3.207 9.701 -2.065 -0.447 -0.980 -4.818 -0.603 -2.742
Max = A[7] = 9.701
//Pascal
const m = 1000
var
arr: array[1..m] of integer;
n,i, j, k: integer;
begin
readln(n);
write ('Исходный массив: ');
for i := 1 to n do begin
readln(arr[i]);
end;
//сортировка методом пузырька
for i := 1 to n-1 do
for j := 1 to n-i do
if arr[j] > arr[j+1] then begin
k := arr[j];
arr[j] := arr[j+1];
arr[j+1] := k
end;
write ('Отсортированный массив: ');
for i := 1 to n do
write (arr[i]:4);
end.
Алгоритм сортировки на классическом языке программирования С
# define SWAP(A,B) {A=A^B;B=A^B;A=A^B;}
void bubblesort(int A[], int n)
{
int i, j;
for(i = n-1 ; i > 0 ; i--)
{ for(j = 0 ; j < i ; j++)
{
if( A[j] > A[j+1] ) SWAP(A[j],A[j+1]);
}
}
}