平方公式的计算,C语言

Problem Description
You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.

Input
In each case, there is an odd positive integer n.

Output
Print the sum. Make sure the sum will not exceed 2^31-1

Sample Input
3

Sample Outp

https://www.cnblogs.com/zqxLonely/p/4088238.html

#include
#define N 10 /* 宏定义N个数 /
void main()
{
int i, sum = 0;
for(i = 1; i < N; i++)
{
sum += i*i; /
前N个数的平方和 */
}
printf("sum=%d\n",sum);
}

把N后面那个数该为你想计算的就行了