自己写的TSL,随机生成j位字母的.
#---------------随机取j个字母----------------------------public function getLetter(in j,out Result)
{
auto i,RandNum,TempLetter;
static Letter[ ]= {"a","b","c", "d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
if(j<0) j=-j;
j=int(j);
for (i=0; i<j; i++)
{
RandNum = int(rand()*25+1);#随机从0-25取一个数字
TempLetter=Letter;
if(TempLetter=="") pause("程序有错!");
Result=Result&TempLetter;
}
printf(Result);
return 0;
}
for (i=0;i<10;i++)
{
getLetter(0);
}
[ 本帖最后由 madduck 于 2007-6-29 11:11 编辑 ]
本贴星期六晚上解封。
搞了一个晚上,终于出来了。欢迎大家指教!版主,我好穷!救济一下啦。[ 本帖最后由 madduck 于 2007-6-29 11:12 编辑 ] for (i=0;i<10;i++)
{
getLetter(0);
}
这里是否应该是getLetter(i)?如果总是赋值0,传过去的参数就不会变化,最后result也是不变的了 后面的for语句是测试时写上去的,意思是取0个字母,取10次。getLetter(j)表示是要随机取j个字母。真正要调用的时,要修改为:
#---------------随机取j个字母----------------------------
public function getLetter(in j,out Result)
{
auto i,RandNum,TempLetter;
static Letter[ ]= {"a","b","c", "d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
if(j<0) j=-j;
j=int(j);
for (i=0; i<j; i++)
{
RandNum = int(rand()*25+1);#随机从0-25取一个数字
TempLetter=Letter;
Result=Result&TempLetter;
}
return Result;
}
[ 本帖最后由 madduck 于 2007-6-30 22:49 编辑 ]
页:
[1]