实验4

include <stdio.h>

include <stdlib.h>

include <gmp.h>

int main()
{
mpz_t product, num;
int i;

// 初始化大数库
mpz_init(product);
mpz_init(num);
mpz_set_ui(product, 1);

// 计算20201211到20201226的乘积
for (i=20201211; i<=20201226; i++) {
    mpz_set_ui(num, i);
    mpz_mul(product, product, num);
}

// 输出结果
gmp_printf("20201211到20201226的乘积为: %Zd\n", product);

// 释放内存
mpz_clear(num);
mpz_clear(product);

return 0;

}

posted @ 2023-05-10 09:05  棉被王Excalibur  阅读(3)  评论(0编辑  收藏  举报