我的第18个代码
作者:互联网
我的第十八个代码
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int a = 1;
int ret = 1;
int n = 1;
int sum = 0;
for (n = 1; n <= 10; n++)
{
ret = 1;
for (a = 1; a <= n; a++)
{
ret = a*ret;
}
sum = ret + sum;
}
printf("%d\n", sum);
return 0;
}//计算1!+2!+3!……10!的结果
int main()
{
int a = 1;
int ret = 1;
int n = 1;
int sum = 0;
for (n = 1; n <= 10; n++)
{
ret = ret*n;
sum = ret + sum;
}
printf("%d\n", sum);
return 0;
}//计算1!+2!+3!……10!的结果(对上面代码的优化)
标签:第十八个,SECURE,CRT,int,18,代码,main 来源: https://blog.51cto.com/15100722/2633206