BREEZE


私信TA

用户名:MILD

访问量:12402

签 名:

不到100不关电脑

等  级
排  名 1861
经  验 2498
参赛次数 12
文章发表 27
年  龄 16
在职情况 学生
学  校 省丹中(镇江丹阳)
专  业 高二

  自我简介:

#include<stdio.h>

 

int M=0; 

 

void  huanping(int c); 

 

int main()

{

  int n[1000];  // 瓶子数量

  int i=0;

  scanf("%d",&n[0]);

 

  while(n[i]!=0)

  {

    i++;

    scanf("%d",&n[i]);

 

  } 

  for(int j=0;j<i;j++)

  {

   M=0;

   huanping(n[j]);

   printf("%d\n",M);

  }

 

  return 0;

}

 

void  huanping(int c)

{

  if(c<=1)

  return;

  if(c==2)

   {

   M++;return ;

   }

   int c1;

   M=M+c/3;

   c1=c/3+c%3; //compute the number of bottle after exchange

   huanping(c1);

   return ;

 

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区