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
网友评论