1、喝汽水问题。每7个汽水瓶可以换一瓶汽水,输入为n瓶汽水,求得最后能喝到多少瓶汽水

public static int count(int n){
        return n+emptyCount(n);
    }
    public static int emptyCount(int m) {
        int empty;
        int currentStreamWater=m/7;
        if (m < 7) {
            return 0;
        }
        if (m % 7 == 0) {
            empty = currentStreamWater;
        } else {
            empty = currentStreamWater + m % 7;
        }
        return currentStreamWater+emptyCount(empty);
    }
View Code

相关文章:

  • 2022-02-06
  • 2021-12-07
  • 2021-11-28
  • 2021-11-25
猜你喜欢
  • 2021-07-02
  • 2022-02-21
  • 2021-11-14
  • 2022-02-02
  • 2021-11-15
  • 2022-01-03
相关资源
相似解决方案