75% 的时间显示广告

发布于 2024-08-09 15:14:50 字数 97 浏览 2 评论 0原文

75% 的情况下我都在尝试找到一种展示广告的方法。我目前有一个从 1 到 100 之间选择的随机数。如果随机数出现在 1 到 75 之间,我会显示 AD。有没有更好的方法来实现这个

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 implement this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鲸落 2024-08-16 15:14:50

通过这种方法,您可能将在 75% 的时间内展示广告。如果您希望严格达到 75%,则可以使用计数器。

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.

幻梦 2024-08-16 15:14:50

您可以选择 1 到 4 之间的数字,如果是 1 到 3,则展示广告。 :) 但除此之外,没有。您有什么问题吗?

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?

第几種人 2024-08-16 15:14:50

您永远无法在 75% 的情况下准确地显示添加,因为为了确定 75% 的内容,您需要知道该值(在您的情况下为显示数量)。但如果您知道显示的数量,那么您过去一定已经显示过添加;)希望它有意义。

你正在做的事情很好;该添加将以 75% 的概率在每个显示器上显示。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文