Jewels and stones: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 1,467:
3
0
</pre>
 
=={{header|XPL0}}==
<lang XPL0>string 0; \Use zero-terminated strings
 
func Count(Stones, Jewels);
\Return number of letters in Stones that match letters in Jewels
char Stones, Jewels;
int Cnt, I, J;
[Cnt:= 0;
I:= 0;
while Jewels(I) do
[J:= 0;
while Stones(J) do
[if Stones(J) = Jewels(I) then Cnt:= Cnt+1;
J:= J+1;
];
I:= I+1;
];
return Cnt;
];
 
[IntOut(0, Count("aAAbbbb", "aA")); CrLf(0);
IntOut(0, Count("ZZ", "z")); CrLf(0);
IntOut(0, Count("pack my box with five dozen liquor jugs", "aeiou")); CrLf(0);
]</lang>
 
{{out}}
<pre>
3
0
11
</pre>
 
772

edits