慕移动6052691
#include<stdio.h>#include<stdlib.h>void main(){ int sum = 0; int n = 1; for(int i =1;i<=20;i++) { n = n*i; sum += n; } printf("1到20的阶乘和为%d\n",sum); system("pause");}或者:#include<stdio.h>#include<stdlib.h>int fun(int n){ if(n==1) return 1; else return n*fun(n-1);}void main(){ int sum = 0; int n = 1; for(int i =1;i<=20;i++) { //n = n*i; n = fun(i); sum += n; } printf("1到20的阶乘和为%d\n",sum); system("pause");}显然第一种效率高