|
static a1[] = {1, 2, 3, 4};
public key[];
static n;
public function key_num(in n)
{
auto result, i;
result = 1;
for(i=1; i<=n; i++)
result = result * 2;
return result;
}
public function int_to_bstr(in num)
{
auto result, i;
result = "";
i = num;
while(i != 0){
if((i % 2) == 0)
result = ",0" & result;
else
result = ",1" & result;
i = int(i / 2);
}
while(length(result) != 2 * n)
result = ",0" & result;
result = substr(result, 2, length(result) - 1);
return result;
}
public function build_key(in key_num)
{
auto i, j, temp_arr[], result;
for(i=0; i<key_num; i++)
{
result = "";
key[i] = int_to_bstr(i);
split(key[i], temp_arr, ",");
for(j=0; j<n; j++)
if(temp_arr[j + 1] == 1)
result = result & a1[j];
key[i] = result;
}
}
n = 4;
key_number = key_num(n);
build_key(key_number);
for(i=0; i<key_number; i++)
report_msg(key[i]); |
|