program GradesFinder;
var
grades: array[Integer] of Integer;
gradesCounter: array[3..5] of Integer = (0,0,0);
gradesSum: Integer = 0;
mostCommonGradeCounter: Integer = 0;
mostCommonGrade: Integer = 0;
i: Integer;
begin
Randomize;
writeln('Оценки учеников:');
for i:=0 to 19 do
grades[i] := 3 + Random(3);
writeln(i+1,': ',grades[i]);
gradesCounter[grades[i]] := gradesCounter[grades[i]] + 1;
gradesSum := gradesSum + grades[i]
end;
writeln('Число отметок 5: ', gradesCounter[5]);
writeln('Средний бал: ', gradesSum/20:2:1);
write('Болше всего получено: ');
for i := 3 to 5 do
if mostCommonGradeCounter < gradesCounter[i] then
mostCommonGrade := i;
mostCommonGradeCounter := gradesCounter[i];
writeln(mostCommonGrade);
end.
Объяснение:
program Arrays;
input: array[Integer] of Integer;
largestElement: Integer = 0;
smallestElement: Integer = 999;
smallestElementPosition: Integer = 18;
for i:=0 to 18 do
input[i] := Random(700);
writeln('Весь массив:');
writeln(i, ': ', input[i]);
if largestElement < input[i] then
largestElement := input[i];
if smallestElement > input[i] then
smallestElement := input[i];
smallestElementPosition := i;
writeln('Наибольший элемент массива:', largestElement);
writeln('Позиция наименьшего элемента:', smallestElementPosition);
program GradesFinder;
var
grades: array[Integer] of Integer;
gradesCounter: array[3..5] of Integer = (0,0,0);
gradesSum: Integer = 0;
mostCommonGradeCounter: Integer = 0;
mostCommonGrade: Integer = 0;
i: Integer;
begin
Randomize;
writeln('Оценки учеников:');
for i:=0 to 19 do
begin
grades[i] := 3 + Random(3);
writeln(i+1,': ',grades[i]);
gradesCounter[grades[i]] := gradesCounter[grades[i]] + 1;
gradesSum := gradesSum + grades[i]
end;
writeln('Число отметок 5: ', gradesCounter[5]);
writeln('Средний бал: ', gradesSum/20:2:1);
write('Болше всего получено: ');
for i := 3 to 5 do
if mostCommonGradeCounter < gradesCounter[i] then
begin
mostCommonGrade := i;
mostCommonGradeCounter := gradesCounter[i];
end;
writeln(mostCommonGrade);
end.
Объяснение:
program Arrays;
var
input: array[Integer] of Integer;
i: Integer;
largestElement: Integer = 0;
smallestElement: Integer = 999;
smallestElementPosition: Integer = 18;
begin
Randomize;
for i:=0 to 18 do
input[i] := Random(700);
writeln('Весь массив:');
for i:=0 to 18 do
begin
writeln(i, ': ', input[i]);
if largestElement < input[i] then
largestElement := input[i];
if smallestElement > input[i] then
begin
smallestElement := input[i];
smallestElementPosition := i;
end;
end;
writeln('Наибольший элемент массива:', largestElement);
writeln('Позиция наименьшего элемента:', smallestElementPosition);
end.