程序代码:
#include <stdio.h> int main() { int n,i,t,s = 0; printf ("请输入n的值:"); scanf("%d",&n); for (i = 0; i < n; ++i) { printf("请输入第%d个数的值:", i*(n + 1)+1); scanf("%d", &t); s += t; } printf("%d\n", s); return 0; }
#include <stdio.h> int main() { int n,i,t,s = 0; printf ("请输入n的值:"); scanf("%d",&n); for (i = 0; i < n; ++i) { printf("请输入第%d个数的值:", i*(n + 1)+1); scanf("%d", &t); s += t; } printf("%d\n", s); return 0; }