开发者

Show an Advertisement 75% of the Time

I am trying to figure out a way to show an advertisement 75% of the time. I currently have a random number that is selected from 1 to 100. if the random number occurs between 1 and 75 I show the AD. Is there a better way to imple开发者_JAVA技巧ment this


With this approach you're probably going to display the ad 75% of the time. If you want it strictly 75%, you can use a counter.


You could select a number between 1 and 4, and if it's 1 through 3 then show the ad. :) But otherwise, no. What are you having problems with?


You'll never be able to display an add exactly 75% of the time because, in order to determine 75% of something you need to know that value (in your case the number of displays). But if you know the number of displays then you must have shown the add in the past ;) Hope it makes sense.

What you are doing is fine; the add will be displayed with a probability of 75% on each display.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜