用while循环进行求解,代码如下:
int ContinuousMultiplication(int num)
{
int tmp = 1;
while (num)
{
tmp= tmp*num;
num--;
}
return tmp;
}
int main()
{
int i = 0,allnum=0;
for (i = 1; i <= 20; i++)
{
allnum +=ContinuousMultiplication(i);
}
cout << allnum << endl;
system("pause");
return 0;
}
本文出自 “零点时光” 博客,请务必保留此出处http://10741764.blog.51cto.com/10731764/1743353