#include
#include
int main()
int i,y,k,v,x;
printf("输入的初始值y0和要向后累加到k值,计算从y0累加到k的总和S=y+k\n");
scanf("%d%d",&y,&k);
x=(y+1);
printf("\t\t\ty=%d\n\ty和k的初始值=\n\t\t\tk=%d\n%d加到%d\n",y,k,y,k);
for(i=y+1;i<=k;++i)
{
if(i<=k)
if(i<=x)
printf("y=%d\t+\tk=%d\tS=%d\n",i-1,i,y=y+i);
else
printf("S=%d\t+\tk=%d\tS=%d\n",y-i,i,y=y+i);
if(i==k)
printf("最后结果\tS总=%d\n",y);
if(i==k)
{
printf("\n\n输入的初始值y0和要向后累加到k值,计算从y0累加到k的总和S=y+k\n");
printf("\t\t\ty=%d\n\ty和k的初始值=\n\t\t\tk=%d\n%d加到%d\n",x-1,k,x-1,k);
}
}
system("pause");
return 0;
}