Answer the question
In order to leave comments, you need to log in
How to count the number of all elements of an array in the entire span, and not just in 3 places?
How to count the number of all elements of an array in the entire span, and not just in 3 places? (Number - k)
Thanks in advance
procedure TForm1.Button1Click(Sender: TObject);
var
x:array [1..20] of real;
i,n,k: integer ;
s,a,b:real;
begin
n:=strtoint(edit1.text);
stringgrid1.ColCount:=n;
for i:=1 to n do
x[i]:=strtofloat (stringgrid1.Cells[i-1,0]);
a:=strtofloat (edit2.text);
b:=strtofloat (edit3.text);
s:=0 ; k:=0; i:=3;
while i<=n do
begin
if(x[i]>=a) or (x[i]<=b) then
begin
k:=k+1;
s:=s+x[i];
i:=i+3;
end;
label5.caption:='Сумма элемнтов массива на 3-их местах принадлежащих промежутку равно ' + floattostr(s);
label4.caption:='Количество эллементов массива принадлежащих промежутку равно ' + floattostr(k);
end;
end;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question