美文网首页
ginac库求余数/最大公约数/最小公倍数

ginac库求余数/最大公约数/最小公倍数

作者: 一路向后 | 来源:发表于2020-10-12 21:16 被阅读0次

1.程序源码

#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main()
{
        //定义整数
        numeric a = 20;
        numeric b = 30;

        //求余数
        numeric c = mod(30, 20);

        //求最大公约数
        numeric d = gcd(a, b);

        //求最小公倍数
        numeric e = lcm(a, b);

        //打印输出结果
        cout << c << endl;
        cout << d << endl;
        cout << e << endl;

        return 0;
}

2.编译源码

$ g++ -o example example.c -lginac -lcln -I/usr/local/include -L/usr/local/lib64

3.运行结果

./example
10
10
60

相关文章

网友评论

      本文标题:ginac库求余数/最大公约数/最小公倍数

      本文链接:https://www.haomeiwen.com/subject/sywppktx.html