#7014: 拜託拜託幫幫忙 執行會多1ㄟ


boy5tw (揪佑)


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
  int a,b,n,m,x;
  while(scanf("%d %d",&a,&b)==2)
  {
  x=1;m=0;
  for(n=a+1;n<=b;n++)
  { 
  m=a+n;
  if(m>b)
  break;
  ++x;
 
  }
  printf("%d\n",x);
  }
  system("PAUSE");
  return 0;
}

#7016: Re:拜託拜託幫幫忙 執行會多1ㄟ


passerr (20130326 0340 48)


不知道要怎麼回答

你看看差別在哪裡

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
    int a,b,n,m,x;
    while(scanf("%d %d",&a,&b)==2)
    {
        x=1;m=0;
        for(n=a;;n++)
        {
            m+=n;
            if(m>b)
            break;
            ++x;
        }
        printf("%d\n",x);
    }
    return 0;
}