Как написать в pascal abc программу которая Определяет является ли последовательность арифметической прогрессией

21 Апр 2020 в 19:40
180 +1
0
Ответы
1

program ArithmeticProgression;

var
arr: array[1..100] of integer;
n, d, i: integer;
isArithmetic: boolean;

begin
write('Enter the number of elements in the sequence: ');
readln(n);

write('Enter the first element of the sequence: ');
readln(arr[1]);

write('Enter the common difference: ');
readln(d);

isArithmetic := true;

for i := 2 to n do
begin
arr[i] := arr[i-1] + d;

if (arr[i] <> arr[i-1] + d) then
begin
isArithmetic := false;
break;
end;

end;

if isArithmetic then
writeln('The sequence is an arithmetic progression.')
else
writeln('The sequence is not an arithmetic progression.');

end.

18 Апр 2024 в 13:33
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир