关于c语言循环
n 2 k 24、求 ∑ 2j^2 + ∑ i!(-1)^i
j = n 1 i = k 1 其中n1、n2键盘输入, 输错重输(如:n1>n2),k1>k2同上
不要太难,我目前只学到数组
#include < stdio.h > #include < stdlib.h > #include < math.h > void main ( ) { double n1, n2, k1, k2, t, j, i, m = 1, sum, sum1 = 0,sum2 = 0; printf ( "输入4个数,第二个比第一个大,第四个比第三个大\n" ); scanf ( "%f%f%f%f", &n1, &n2, &k1, &k2 ); for ( i = n1; i <= n2; i++ ) sum1 = sum1 + 2*i*i; printf ( "%f\n", sum1 ); for ( j = k1; j <= k2; j++ ) { for ( t = 1; t <= k1; t++ ) m = m * t; sum2 = sum2 + m * pow ( -1, i ); printf ( "%f\n", sum2 ); } sum = sum1 + sum2; printf ( "%f", sum ); system ( "pause" ); }累死了,还是没有写出来,谁知道我错哪了么