欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c語言求階乘精確值示例

 更新時(shí)間:2014年03月28日 09:56:08   作者:  
這篇文章主要介紹了c語言求階乘精確值示例,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

#include <stdio.h>
#include <string.h>
const int maxn = 3000;
int f[maxn];
int main()
{
 int i,j,n;
 scanf("%d",&n);
 memset(f,0,sizeof(f));
 f[0] = 1;
 for(i = 2;i <= n;i++)
 {
  int c = 0;
  for(j = 0;j < maxn;j++)
  {
   int s = f[j] * i + c;
   f[j] = s % 10;
   c = s / 10;
  }
 }
 for(j = maxn - 1;j >= 0;j--) if(f[j]) break;
 for(i = j;i >= 0;i--) printf("%d",f[i]);
 printf("\n");
 return 0;
}

相關(guān)文章

最新評(píng)論