首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >增量然后每隔10次递减一次

增量然后每隔10次递减一次
EN

Stack Overflow用户
提问于 2015-08-27 00:49:01
回答 2查看 117关注 0票数 0

我正在为幻想制作一个草稿应用程序。正因为如此,每10支球队就会向后选择。是否有一种简单的方法来做到这一点,或者我是否需要编写一个长if/ ext、switch、ext语句?

示例:

  • 挑选队
  • 1-1
  • 2-2
  • 3-3
  • 4 -4
  • 5-5
  • 7-7
  • 8-8
  • 9-9
  • 10 - 10
  • 11 - 10
  • 12-9
  • 诸若此类
EN

回答 2

Stack Overflow用户

发布于 2015-08-27 00:54:46

使一个布尔变量存储我们正在递增或递减的天气,然后是一个字节来存储您增加/减少了多少次,并创建一个循环。在布尔值中使用if/else。不要忘记每次翻转布尔值。

票数 0
EN

Stack Overflow用户

发布于 2015-08-27 01:01:45

像这样的应该能完成任务:

代码语言:javascript
运行
复制
var total_picks = 100;
var current_pick = 1;
var current_team = 1;
var my_test = true;

for (var i = 0; i < total_picks; i++) {

  // In this "if" statement, the team number will count up from 1 to 10
  if (my_test) {

    // Do whatever you want to with the current pick here
    current_pick++;

    // Do whatever you want to with the current team here
    current_team++;

    if (current_team == 10) {
      my_test = false;
    }
  } else {
    // In this "else" statement, the team number will count down from 10 to 1

    // Do whatever you want to with the current pick here
    current_pick++;

    // Do whatever you want to with the current team here
    current_team--;
    if (current_team == 0) {
      my_test = true;
    }
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32238958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档