题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
#include <stdio.h> int main() { int n=0; scanf("%d",&n); int arr[1000]; for (int i=0; i<1000; i++) { arr[i]=3*(i+1)-1; } int sum = 0; if (n>=1&&n<=1000) { for (int j=0; j<n; j++) { sum=sum+arr[j]; } } printf("%d",sum); return 0; }#算法##华为机试题##华为##c语言#