这题有很多种解决方案;但是觉得有些方案有写欠缺.下面给出我的解决方案:
题目是求n!结果有零的个数,所以不必求出n!的结果,可以用n来判断:
int c(int x)
{
int a,count=0;
for(a=5;a<=n;a++)
{if(a%5==0)count++;
if(!(a%25))count++;}
return count;
}
int main()
{
int n;
printf("please input a number:\n");
scanf("%d",&n);
printf("the number of %d! at the end have %d zero",n,c(n));
}