Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
47
Task/Text-processing-1/PureBasic/text-processing-1.basic
Normal file
47
Task/Text-processing-1/PureBasic/text-processing-1.basic
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#TASK="Text processing/1"
|
||||
Define File$, InLine$, Part$, i, Out$, ErrEnds$, Errcnt, ErrMax
|
||||
Define lsum.d, tsum.d, rejects, val.d, readings
|
||||
|
||||
File$=OpenFileRequester(#TASK,"readings.txt","",0)
|
||||
If OpenConsole() And ReadFile(0,File$)
|
||||
While Not Eof(0)
|
||||
InLine$=ReadString(0)
|
||||
For i=1 To 1+2*24
|
||||
Part$=StringField(InLine$,i,#TAB$)
|
||||
If i=1 ; Date
|
||||
Out$=Part$: lsum=0: rejects=0
|
||||
ElseIf i%2=0 ; Recorded value
|
||||
val=ValD(Part$)
|
||||
Else ; Status part
|
||||
If Val(Part$)>0
|
||||
Errcnt=0 : readings+1
|
||||
lsum+val : tsum+val
|
||||
Else
|
||||
rejects+1: Errcnt+1
|
||||
If Errcnt>ErrMax
|
||||
ErrMax=Errcnt
|
||||
ErrEnds$=Out$
|
||||
EndIf
|
||||
EndIf
|
||||
EndIf
|
||||
Next i
|
||||
Out$+" Rejects: " + Str(rejects)
|
||||
Out$+" Accepts: " + Str(24-rejects)
|
||||
Out$+" Line_tot: "+ StrD(lsum,3)
|
||||
If rejects<24
|
||||
Out$+" Line_avg: "+StrD(lsum/(24-rejects),3)
|
||||
Else
|
||||
Out$+" Line_avg: N/A"
|
||||
EndIf
|
||||
PrintN("Line: "+Out$)
|
||||
Wend
|
||||
PrintN(#CRLF$+"File = "+GetFilePart(File$))
|
||||
PrintN("Total = "+ StrD(tsum,3))
|
||||
PrintN("Readings = "+ Str(readings))
|
||||
PrintN("Average = "+ StrD(tsum/readings,3))
|
||||
Print(#CRLF$+"Maximum of "+Str(ErrMax))
|
||||
PrintN(" consecutive false readings, ends at "+ErrEnds$)
|
||||
CloseFile(0)
|
||||
;
|
||||
Print("Press ENTER to exit"): Input()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue