Modular arithmetic
 
Betöltés...
Keresés...
Nincs egyezés
main.cpp
Ugrás a fájl dokumentációjához.
1
2#include "mod.h"
3#include <iostream>
4using namespace std;
5
7
8static void testMod() {
9 bme::Mod x, y, z;
10
13 cout << "Print mode: normal" << endl << endl;
14
15 x = bme::Mod(17, 10);
16 y = bme::Mod(24);
17 z = -3;
18
19 cout << "x = " << x << endl;
20 cout << "y = " << y << endl;
21 cout << "z = " << z << endl << endl;
22
23 cout << "x+y = " << x + y << endl;
24 cout << "y+z = " << y + z << endl;
25 cout << "y-z = " << y - z << endl;
26 cout << "y*z = " << y * z << endl;
27 cout << "y/z = " << y / z << endl << endl;
28
29 cout << "x+3 = " << x + 3 << endl;
30 cout << "x-3 = " << x - 3 << endl;
31 cout << "x*3 = " << x * 3 << endl;
32 cout << "x/3 = " << x / 3 << endl << endl;
33
34 cout << "4+x = " << 4 + x << endl;
35 cout << "4-x = " << 4 - x << endl;
36 cout << "4*x = " << 4 * x << endl;
37 cout << "4/x = " << 4 / x << endl << endl;
38
39 cout << "-x = " << -x << endl << endl;
40
41 cout << "x^9 = " << x.pow(9) << endl;
42 cout << "x^(-9) = " << x.pow(-9) << endl << endl;
43
44
45 cout << "-1+y^10 = " << -1 + y.pow(10) << endl << endl;
46
48 cout << "Print mode: short" << endl << endl;
49
50 cout << "y^2 = " << y.pow(2) << endl;
51 cout << "y^(-2)+1 = " << y.pow(-2) + 1 << endl << endl;
52
53 cout << "x == 17\t" << (x == 17) << endl;
54 cout << "x != 17\t" << (x != 17) << endl;
55 cout << "17 == x\t" << (17 == x) << endl;
56 cout << "17 != x\t" << (17 != x) << endl;
57}
58
59int main() {
60 testMod();
61 return 0;
62}
Definition mod.h:24
static void set_default_modulus(int _def_mod)
Default modulus beállítása.
Definition mod.h:133
static void set_short_print_mode()
Kiírás módjának beállítása.
Definition mod.h:151
static void set_normal_print_mode()
Kiírás módjának beállítása.
Definition mod.h:142
Mod pow(int k) const
Hatványozás.
Definition mod.cpp:35
int main()
Definition main.cpp:59
a mod n maradékosztályok gyűrűjét reprezentáló osztály