Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
47
Task/CUSIP/Yabasic/cusip.basic
Normal file
47
Task/CUSIP/Yabasic/cusip.basic
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
sub cusip(inputStr$)
|
||||
local i, v, sum, x$
|
||||
|
||||
Print inputStr$;
|
||||
If Len(inputStr$) <> 9 Print " length is incorrect, invalid cusip" : return
|
||||
|
||||
For i = 1 To 8
|
||||
x$ = mid$(inputStr$, i, 1)
|
||||
switch x$
|
||||
Case "*": v = 36 : break
|
||||
Case "@": v = 37 : break
|
||||
Case "#": v = 38 : break
|
||||
default:
|
||||
if x$ >= "A" and x$ <= "Z" then
|
||||
v = asc(x$) - Asc("A") + 10
|
||||
elsif x$ >= "0" and x$ <= "9" then
|
||||
v = asc(x$) - asc("0")
|
||||
else
|
||||
Print " found a invalid character, invalid cusip"
|
||||
return
|
||||
end if
|
||||
End switch
|
||||
|
||||
If and(i, 1) = 0 v = v * 2
|
||||
sum = sum + int(v / 10) + mod(v, 10)
|
||||
Next
|
||||
|
||||
sum = mod(10 - mod(sum, 10), 10)
|
||||
If sum = asc(mid$(inputStr$, 9, 1)) - Asc("0") Then
|
||||
Print " is valid"
|
||||
Else
|
||||
Print " is invalid"
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
// ------=< MAIN >=------
|
||||
|
||||
Data "037833100", "17275R102", "38259P508"
|
||||
Data "594918104", "68389X106", "68389X105", ""
|
||||
|
||||
Print
|
||||
do
|
||||
Read inputStr$
|
||||
if inputStr$ = "" break
|
||||
cusip(inputStr$)
|
||||
loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue