/*求等差数列的和*/
#include
int sum(int start,int dk,int num){
int i=0;
int temp=0;
int end=start;
for(i;i
end=end+dk;
}
return temp;
}//sum()
int main()
{
int start;
int dk;
int num;
printf("输入首项 start= \n");
scanf("%d",&start);
printf("输入公差 dk= \n");
scanf("%d",&dk);
printf("输入项数 num= \n");
scanf("%d",&num);
int summation=sum(start,dk,num);
printf("和是 ");
printf("%d",summation);
printf("\n");
return;
}//main()
#include
void main(){
long first,last,count,step;
scanf("%l%l%l%l",&first,&last,&count,&step);
printf("sum=%l",((first+last)*count)/(2*step));
}
step不能为0