51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1672|回复: 1
打印 上一主题 下一主题

[原创] 求教各位大侠代码中取到的随机数有什么用

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-3-19 18:13:29 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
请教各位大侠,下面代码中的randnum=rand()%3+3;在这里有什么用,小女子知道rand()%3+3取得到的随机数是3到5,但是不是很清楚放在这段代码中有什么用。

int randnum,x,i;
        web_url("localhost",
                "URL=http://localhost/",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Snapshot=t1.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=/Comm_Images/home-bg-body.gif", ENDITEM,
                "Url=/Comm_Images/Logo-home.gif", ENDITEM,
                "Url=/Comm_Images/seahorse.gif", ENDITEM,
                "Url=/Comm_Images/bg-search.gif", ENDITEM,
                "Url=/Comm_Images/button-search.gif", ENDITEM,
                "Url=/Comm_Images/home-fish.gif", ENDITEM,
                "Url=/Comm_Images/dotten-line.gif", ENDITEM,
                "Url=/WebResource.axd?d=KfvnEgkqAkSl4HiG-EFY7w2&t=633439354840000000", ENDITEM,
                LAST);

        randnum=rand()%3+3;
    lr_output_message("%d",randnum);


        for(i=0;i<randnum;i++)
        {
                lr_save_string(lr_eval_string("{categoryid}"),"temp");
        web_url(lr_eval_string("{temp}"),
                "URL=http://localhost/Products.aspx?page=0&categoryId={temp}",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://192.168.0.200:8080/",
                "Snapshot=t2.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=/Comm_Images/button-wishlist-grey.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/bg-body.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/button-checkout.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/bg-sign-in.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/Logo.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/button-cart-grey.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/vertigo-icon.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Prod_Images/Birds/icon-penguin.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/spacer.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Prod_Images/Birds/icon-pelican.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Prod_Images/Birds/icon-duck.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                "Url=/Prod_Images/Birds/icon-owl.gif", "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS", ENDITEM,
                LAST);

        web_url(lr_eval_string("{productid}"),
                "URL=http://localhost/Items.aspx?productId={productid}&categoryId={temp}",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://localhost/Products.aspx?page=0&categoryId=BIRDS",
                "Snapshot=t3.inf",
                "Mode=HTML",
                EXTRARES,
                "Url=/Prod_Images/Birds/item-owl-day.gif", "Referer=http://localhost/Items.aspx?productId=BD-04&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/button-cart.gif", "Referer=http://localhost/Items.aspx?productId=BD-04&categoryId=BIRDS", ENDITEM,
                "Url=/Prod_Images/Birds/item-owl-night.gif", "Referer=http://localhost/Items.aspx?productId=BD-04&categoryId=BIRDS", ENDITEM,
                "Url=/Comm_Images/button-wishlist.gif", "Referer=http://localhost/Items.aspx?productId=BD-04&categoryId=BIRDS", ENDITEM,
                LAST);
ps:云层老师的代码,当时培训的时候将到的,但是现在看起来就不太清楚什么意思了
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2009-3-19 20:50:37 | 只看该作者
随机执行3到5次操作吧!就是那个购物网站,随机任意点击3-5次,应该是的吧!
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-27 10:37 , Processed in 0.067496 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表