The program introduces a string of numbers separated by pluses, such as '123 + 456 + 789 + 456'. The result of the program is a column of numbers present in the string, ignoring the latter, such as '123 456 789' Help! Correctly displays 2 numbers, and then writes 'The input line had the wrong format, error: line 24'

uses crt; var sumi:array [1..10] of real; i,l,posit,d,n,f:integer; c,a,b:real; s:string[100];sums,chsl:string; begin n:=0; read (s); l:=(ord(s[0])); posit:=Pos ('+',s); while posit<>0 do begin sums:=''; chsl:=''; posit:=Pos ('+',s); n:=n+1; if posit=1 then delete (s,1,1) else begin For i:=1 to (posit-1) do begin chsl:=s[1]; sums:=sums+chsl; delete (s,1,1); end; sumi[n]:=strtofloat(sums); delete (s,1,1); writeln('!',sumi[n]); end; end; end. 
  • posit:=Pos ('+',s); in the body of the cycle, you must move it to its end, otherwise you first check for the presence of pluses in the line, and then remove them from there. - Alekcvp
  • Thanks a lot, helped. From now on I will be more attentive.) - Motya

0