Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/CUSIP/XPL0/cusip.xpl0
Normal file
39
Task/CUSIP/XPL0/cusip.xpl0
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
string 0; \use zero-terminated strings
|
||||
|
||||
func Valid(Cusip); \Return 'true' if valid CUSIP code
|
||||
char Cusip;
|
||||
int Sum, I, C, V;
|
||||
[Sum:= 0;
|
||||
for I:= 0 to 8-1 do
|
||||
[C:= Cusip(I);
|
||||
ChOut(0, C);
|
||||
case of
|
||||
C>=^0 & C<=^9: V:= C-^0;
|
||||
C>=^A & C<=^Z: V:= C-^A+10;
|
||||
C=^*: V:=36;
|
||||
C=^@: V:=37;
|
||||
C=^#: V:=38
|
||||
other V:= -1;
|
||||
if I&1 then V:= V*2;
|
||||
Sum:= Sum + V/10 + rem(0);
|
||||
];
|
||||
C:= Cusip(I);
|
||||
ChOut(0, C);
|
||||
V:= rem( (10-rem(Sum/10)) / 10 );
|
||||
return V = C-^0;
|
||||
];
|
||||
|
||||
int Cusip, N;
|
||||
[Cusip:= ["037833100",
|
||||
"17275R102",
|
||||
"38259P508",
|
||||
"594918104",
|
||||
"68389X106",
|
||||
"68389X105"];
|
||||
for N:= 0 to 6-1 do
|
||||
[Text(0, if Valid(Cusip(N))
|
||||
then " is valid"
|
||||
else " is invalid");
|
||||
CrLf(0);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue