实验二

'''

include <stdio.h>

include <stdlib.h>

include <string.h>

include <openssl/bn.h>

int main()
{
BIGNUM *product, *num;
char *str;
int i;

// 初始化大数库
BN_CTX *ctx = BN_CTX_new();
product = BN_new();
num = BN_new();
str = BN_bn2dec(product);
BN_set_word(product, 1);

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

// 输出结果
str = BN_bn2dec(product);
printf("20201211到20201226的乘积为: %s\n", str);

// 释放内存
BN_free(num);
BN_free(product);
BN_CTX_free(ctx);
free(str);

return 0;

}
'''

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