问题描述
public string GenerateCardTokenoptimised()
{
int[] checkArray = new int[15];
var cardNum = new int[16];
for (int d = 14; d >= 0; d--)
{
cardNum[d] = _random.Next(0,9);
checkArray[d] = ( cardNum[d] * (((d+1)%2)+1)) % 9;
}
cardNum[15] = ( checkArray.Sum() * 9 ) % 10;
var sb = new StringBuilder();
for (int d = 0; d < 16; d++)
{
sb.Append(cardNum[d].ToString());
}
return sb.ToString();
}
Rexx似乎没有其他语言的常用数组,那么我该如何实现
解决方法
Rexx具有stem变量。干变量是关联数组,例如Java中的 Map
你可以做
do i = 1 to 10
myArray.i = i
end
您还可以将字符串用作词干变量中的键
color = 'green'
say "Color value: " colorLookup.color
您还可以检查是否找到了东西
false = 0
true = 1
found. = false /* initialize stem to false (0) */
do i = 1 to 10
square = i * i
found.square = true
end
do i = 1 to 100
if found.i = true then do
say i "is a square"
end
end