大数阶乘
#include<iostream> using namespace std; int main() { int n,i,j; int jw; int gw=1; int a=0; int jc[10005]; jc[0] = 1; scanf("%d",&n); for(i=2;i<=n;i++){ for(j=0;j<gw;j++){ jc[j] *= i; } jw = 0; for(j=0;j<gw;j++){ jc[j] = jc[j]+jw; jw = 0; if(jc[j]>=10){ jw += jc[j]/10; jc[j] = jc[j]%10; } } while(jw!=0){ //这里不能用if,因为jw可能大于10 jc[gw++] = jw%10; jw = jw/10; } } for(i=gw-1;i>=0;i--){ printf("%d",jc[i]); } return 0; }