Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic
Normal file
21
Task/ISBN13-check-digit/PureBasic/isbn13-check-digit.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Macro TestISBN13(X)
|
||||
Print(X)
|
||||
If IsISBN13(X) : PrintN(" good") : Else : PrintN(" bad") : EndIf
|
||||
EndMacro
|
||||
|
||||
Procedure.b IsISBN13(ISBN13.s)
|
||||
ISBN13=Left(ISBN13,3)+Mid(ISBN13,5)
|
||||
If IsNAN(Val(ISBN13)) Or Len(ISBN13)<>13 : ProcedureReturn #False : EndIf
|
||||
Dim ISBN.s{1}(12) : PokeS(@ISBN(),ISBN13)
|
||||
For i=0 To 11 Step 2 : sum+Val(ISBN(i))+Val(ISBN(i+1))*3 : Next
|
||||
sum+Val(ISBN(12))
|
||||
ProcedureReturn Bool(sum%10=0)
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
TestISBN13("978-1734314502")
|
||||
TestISBN13("978-1734314509")
|
||||
TestISBN13("978-1788399081")
|
||||
TestISBN13("978-1788399083")
|
||||
Input()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue