首页 > 试题广场 >

#include const int u[...

[填空题]
#include <stdio.h>
const int u[3] = {1, -3, 2};
const int v[2] = {-2, 3};
int g(int n){
    int i, sum = 0;
    for (i = 1; i <= n; i++) sum += u[i % 3] * i;
    return sum;
}
int main( ){
    int n, i, sum = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) sum += v[i % 2] * g(i);
    printf("%d\n", sum);
    return 0;
}
输入:103
输出:1

这道题你会答吗?花几分钟告诉大家答案吧!