level 4
刚才在c语言吧发的没人理睬,这里我相信应该有人看吧
2014年12月28日 01点12分
1
level 4
// Rand 3
//10的poa次方
int poww(int poa)
{
int poi, gett = 1;
if (poa == 0)
return 1;
for (poi = 1; poi <= poa; poi++)
{
gett = 10 * gett;
}
return gett;
}
//字符串转数字
int cton(char snum[])
{
int rnnum, arrr;
char snumm[] = "0123456789";
int ctoni, ctonii;
for (ctoni = 0; ctoni <= strlen(snum) - 1; ctoni++)
for (ctonii = 0; ctonii <= strlen(snumm) - 1; ctonii++)
{
if (snum[ctoni] == snumm[ctonii])
{
arrr = ctonii * poww(strlen(snum) - ctoni - 1);
rnnum += arrr;
}
}
return rnnum;
}
//随机数表(外部函数可修改)
char randf[] =
"4685680458221
18454423354
674584094699778282
18029838452
72444424956688465640
13782034928
3465268154379264386928649572168296084328560286273427586222857645
18349546213
479756556258
18856458725
9469642482464646
15583592554
6525655882857080462
13588098104
22543892828456825
18349884899
4077531827428";
int isntfirst, nowh;
//随机函数
int randd(int min, int max)
{
char wait3[10];
srand((int)time(NULL));
int nowhh = rand() % strlen(randf) + 1;
if (!isntfirst)
{
no
2014年12月28日 01点12分
4
level 4
if (!isntfirst)
{
nowh = nowhh;
isntfirst = 1;
}
// 从randf中选择三位数字
sprintf(&wait3, "%c%c%c", randf[nowh], randf[nowh + 1], randf[nowh + 2]);
nowh += 3;
if (nowh + 2 > strlen(randf))
nowh = nowhh;
srand((int)time(NULL) + cton(wait3));
return rand() % (max - min + 1) + min;
}
2014年12月28日 01点12分
5
level 4
由于c4droid上面许多现成的函数有问题,结果不对(或者不好用),而且我对许多现成的函数不了解,我就自己写了外加函数, 如poww是算10的poa次方,考虑到随机数表字太多,所以用字符串储存,这就需要用到cton将其转为数字(我还不了解其他的函数能不能同样这样), 执行过程:如果是第一次,就随机任取随机数表中的一位;如果不是第一次,就依次向后读三位数与时间数相加。这样就可以避免循环函数执行太快,而且建议大家随机数要多写几行,这样基本上算是随机了
2014年12月28日 01点12分
6
level 4
C4droid仔们编许多东西要随机数吧,给你们的元旦大礼
2014年12月28日 01点12分
7
为什么我用C4没办法生成随机数
2017年11月14日 00点11分
level 8
不明觉厉
白天么么哒,晚上啪啪啪,走廊啪啪啪,厨房啪啪啪,阳台啪啪啪,客厅啪啪啪,卧室啪啪啪,浴缸啪啪啪,沙发啪啪啪。椅子啪啪啪,板凳啪啪啪,醒来萌萌哒
2014年12月28日 06点12分
19