#include #include "Zm.h" using namespace std; int main() { while (true) { int m, n; int d, u, v; cout << "m, n: "; cin >> m >> n; if (!cin.good()) break; cout << "gcd(m, n) = " << gcd(m, n) << endl; extEucl(m, n, d, u, v); cout << "Extended Euclid\'s Algorithm:\n" << "d = " << d << " u = " << u << " v = " << v << endl; cout << "powerMod: input a, n, m: "; int a; cin >> a >> n >> m; if (!cin.good()) break; cout << "a^n (mod m) = " << powermod(a, n, m) << endl; cout << "=========================" << endl; Zm x, y; cout << "Input m: "; cin >> m; if (!cin.good()) break; Zm::setMod(m); cout << "Input x, y in Zm: "; cin >> x >> y; if (!cin.good()) break; cout << "x + y = " << x + y << " x*y = " << x*y << endl; cout << "x.inverse() = " << x.inverse() << " x/y = " << x/y << endl; } return 0; }