??
题目描述:
sum=2+5+8+11+14+…,输入正整数n,求sum的前n项和。
输入:
输出:
#include <stdio.h>
int main(void){int i,n,sum;printf("Input n(int n>0)...\nn=");if(scanf("%d",&n)!=1 || n<1){printf("Input error, exit...\n");return 0;}for(sum=0,i=2;n;sum+=i,i+=3,n--);printf("The result is %d\n",sum);return 0;
}