cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              var changing = function(money, price){
  var count = parseInt(money/price),
      bottle = count,
      lid = count,
      lidRate = 4,
      bottleRate = 2;
  (function change(){
    // 兑换盖子
    if(lid >= lidRate){
      var lGet = parseInt(lid/lidRate);
      count += lGet;
      bottle += lGet;
      lid -= lGet*(lidRate-1);
      console.log('使用瓶盖'+ lGet*lidRate +'个,兑换:'+ lGet +'瓶');
      console.log('已喝:'+ count + ', 剩余瓶盖:'+ lid +', 剩余空瓶:'+ bottle);
    // 兑换空瓶
    if(bottle >= bottleRate){
      var bGet = parseInt(bottle/bottleRate);
      count += bGet;
      bottle -= bGet;
      lid += bGet*(bottleRate-1);
      console.log('使用空瓶'+ bGet*bottleRate +'个,兑换:'+ bGet +'瓶');
      console.log('已喝:'+ count + ', 剩余瓶盖:'+ lid +', 剩余空瓶:'+ bottle);
    // 判断剩余
    if(bottle >= bottleRate || lid >= lidRate){
    } else {
      console.log('总共喝:'+ count + ', 剩余瓶盖:'+ lid +', 剩余空瓶:'+ bottle);
// 开始计算
changing(10, 2); 
Loading ..................