#include<stdio.h>main(){ int a,b,c,d=0,f; printf("请依次输入等差数列的首项、公差、项数:"); scanf("%d%d%d",&a,&b,&c); a=f;while(d<=c) { a-=b; f+=a; d+=1; } printf("%d",f);//7=10-3,17=10+7//0=0+1}