#include <stdio.h> int main() { int n = 0;//输入整数 scanf("%d", &n); int i = 0;//遍历 int sum = 0; for (i = 1; i <= n; i++) { int j = 0; int t= 0 ; for (j = 1; j<=i;j++) { t += j; } sum += t; } printf("%d\n", sum); return 0; }
#include <stdio.h> int main() { int n = 0;//输入整数 scanf("%d", &n); int i = 0;//遍历 int sum = 0; for (i = 1; i <= n; i++) { int j = 0; int t= 0 ; for (j = 1; j<=i;j++) { t += j; } sum += t; } printf("%d\n", sum); return 0; }