C语言#include
void main()
{
int n=1,i,sum=0,num=1;
do
{
num=1;
for(i=n;i>0;i--)
num*=i;
sum=sum+num;
n++;
} while(n<=10);
printf("(1->10)! is %d\n",sum);
}
C++编写#include
using namespace std;
void main()
{
int n=1,i,sum=0,num=1;
while(n<=10)
{
num=1;
for(i=n;i>0;i--)
num*=i;
sum+=num;
n++;
}
cout<