大数——10000以内的阶乘

刚开始看到这个题目的时候,无从下手,后来查了大数运算的原理,是使用数组来模仿大数的运算,可以做到大数的加,减,乘运算。

#define N 9999 
int a[N * 5] = { 1 };
int main(){

    int num = N; int len = 1,temp=0,i;
    for (; num;num--){
        for (i = 0; i < len; i++){
            a[i] = a[i] * num + temp;
            temp = a[i]/10000;
            a[i] = a[i] % 10000;
        }
        if (temp){
            a[len++] = temp;
            temp = 0;
        }
    }
    for (; len;) cout << a[--len];

}

相关文章

自1998年我国取消了福利分房的政策后,房地产市场迅速开展蓬...
文章目录获取数据查看数据结构获取数据下载数据可以直接通过...
网上商城系统MySql数据库设计
26个来源的气象数据获取代码
在进入21世纪以来,中国电信业告别了20世纪最后阶段的高速发...