S=1^2-2^2+3^2-4^2+5^2.+(-1)^(n-1)*n^2
=(1-2)*(1+2)+(3-4)(3+4)+……(n-1-n)(n-1+n)
=-3-7-……-(2n-1) 这里共有(2n-1-3)/4+1=0.5n个数
=-(3+2n-1)*0.5n/2
=-0.5n(n+1)
S=1^2-2^2+3^2-4^2+5^2.+(-1)^(n-1)*n^2
=(1-2)*(1+2)+(3-4)(3+4)+……(n-1-n)(n-1+n)
=-3-7-……-(2n-1) 这里共有(2n-1-3)/4+1=0.5n个数
=-(3+2n-1)*0.5n/2
=-0.5n(n+1)