PAT:循环-07. 爬动的蠕虫(15) 错两个

#include<stdio.h>
#include<math.h>
int main()
{
  int a,b,c,tmp=0,time=0,tag=0;
  scanf("%d%d%d",&a,&b,&c);
  while(tmp<=a)
  {
    if(tag==0)
    {
      ++time;
      tmp+=b;
      tag=1;
    }
    else
    {
      ++time;
      tmp-=c;
      tag=0;
    }
  }
  printf("%d
",time);
  return 0;
}
原文地址:https://www.cnblogs.com/Evence/p/4290854.html