#include <stdio.h>
int main(){
int i,j,sum=1,n=1;
while(scanf("%d%d",&i,&j) != EOF){
while(i<j)
{
sum=sum+1;
i=i+sum;
n=n+1;
}
printf("%d\n",n);
sum=1;
n=1;
}
}
#include
int main(){
int i,j,sum=1,n=1;
while(scanf("%d%d",&i,&j) != EOF){
while(i<j)
{
sum=sum+1;
i=i+sum;
n=n+1;
}
printf("%d\n",n);
sum=1;
n=1;
}
}
1. 外面的while迴圈裡面加sum=i;
(你的sum的意義應該是這次數的數,從i=i+sum;可看出是從第二個開始數)
2. while(i<j)改成while(i<=j)
(超過是大於的意思,等於不算)