|
|
back to boardwrong answer (but works correctly on my computer) uses SysUtils; var a,numb,prov:string; i:integer; begin //a:='1427 0'+#13+#10+' '+'876652098643267843'+#13+'5276538'+#10+' '; readln(a); for i := length(a) downto 1 do begin prov:=copy(a,i,1); if (prov=#13) or (prov=#10) or (prov=#32) then begin if numb<>'' then writeln(FormatFloat('0.0000',(sqrt(strtofloat(numb))))); numb:=''; end else numb:=prov+numb; end; writeln(FormatFloat('0.0000',(sqrt(strtofloat(numb))))); readln; end. Edited by author 05.07.2012 21:19 Re: wrong answer (but works correctly on my computer) How this can work on your computer??? When you do readln(a), the only thing you get in string a is the first line of input. So, you don't process anything behind that. Also, if the last line of input ends with line break, I presume your code will print additional rubbish at the end of output. Read the FAQ and study how to input data in different formats (in this problem it is better to use extended or how long real is called in Pascal?) Edited by author 05.07.2012 23:06 |
|
|