#include<stdio.h>
void main()
{
long int s=1,n;
printf("in put the number:");
scanf("%ld",&n);
for(long int i=1;i<=n;i++)
s=s*i;
printf("the answer is %ld\n",s);
}
#include<stdio.h>
void main()
{
long int s=1,n;
printf("in put the number:");
scanf("%ld",&n);
for(long int i=1;i<=n;i++)
s=s*i;
printf("the answer is %ld\n",s);
}
n!一般都很大,13!既可以超过long
精确计算用数组,近似的用double或者是斯特灵公式。。
不过这代码。。。有这么写的么。。。
下面是我改动的代码,在WIN-TC下运行正常:
#include<stdio.h>
void main()
{
long s=1;
int i,n;
printf("in put the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
s=s*i;
printf("the answer is %ld\n",s);
}