Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // Приведение к [0..6]
- int mod7(int x)
- {
- return (x % 7 + 7) % 7;
- }
- int main()
- {
- // Пусть у нас многочлен P(x) = a*x^2 + b*x + c (для примера)
- // Или расширяйте на степень 3,4 по аналогии
- int a, b, c;
- cout << "Введите a, b, c (F7): ";
- cin >> a >> b >> c;
- a = mod7(a);
- b = mod7(b);
- c = mod7(c);
- bool foundAny = false;
- cout << "Корни (x), где P(x)=0 (mod 7): ";
- for (int x = 0; x < 7; x++)
- {
- int val = mod7(a*x*x + b*x + c);
- if (val == 0)
- {
- cout << x << " ";
- foundAny = true;
- }
- }
- if (!foundAny) cout << "Нет корней в F7";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement