1首先一个随机数
对比内变量里的随机数,是否有重复,如果重复则此次无效,重新生成
2,根据此随机数抽取数据库中数据。
另一个线程负责清空内存变量的数据
即此线程开着一个计时器,然后根据时间来清除数据
希望对你有所帮助
1: 数据库查随即抽取10条QuestionId 放到数组arrayQuestion中arrayQuestion[0-9]="select top 10 QuestionId ,NewID() as random from Question order by random"
2:页面加载时显示第一条(定义变量int n=0)
第一条数据="select QuestionTopic from Question where QuestionId=arrayQuestion[n]"
3:button_onclick事件,点击显示下一条数据
n++
下一条数据="select QuestionTopic from Question where QuestionId=arrayQuestion[n]"
我想我讲的已经够详细了。。。。~~
srand(time(0))int
a
=
1
+
(int)rand()/RAND_MAX*99
在一个数组里把抽取过的数放进去,每次抽时与里面的比较。有相同的重新抽取就可以了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)