Добавил:
Рад, если кому-то помог Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
0
Добавлен:
01.11.2025
Размер:
1.55 Кб
Скачать
#include <iostream>
#include <locale>
using namespace std;

class Octonion {
private:
    double e[8]; // 8 компонент
    
public:
    Octonion(double e0 = 0, double e1 = 0, double e2 = 0, double e3 = 0,
             double e4 = 0, double e5 = 0, double e6 = 0, double e7 = 0) {
        e[0] = e0; e[1] = e1; e[2] = e2; e[3] = e3;
        e[4] = e4; e[5] = e5; e[6] = e6; e[7] = e7;
    }
    
    // Сложение
    Octonion operator+(const Octonion& other) const {
        Octonion result;
        for (int i = 0; i < 8; i++) {
            result.e[i] = e[i] + other.e[i];
        }
        return result;
    }
    
    // Умножение (упрощенное)
    Octonion operator*(const Octonion& other) const {
        Octonion result;
        // Упрощенное умножение - покомпонентное
        for (int i = 0; i < 8; i++) {
            result.e[i] = e[i] * other.e[i];
        }
        return result;
    }
    
    // Вывод
    void print() const {
        cout << e[0];
        for (int i = 1; i < 8; i++) {
            cout << " + " << e[i] << "e" << i;
        }
        cout << endl;
    }
};

int main() {
    setlocale(LC_ALL, "ru_RU.UTF-8");
    
    Octonion o1(1, 2, 3, 4, 5, 6, 7, 8);
    Octonion o2(2, 3, 4, 5, 6, 7, 8, 9);
    
    cout << "Октонион 1: "; o1.print();
    cout << "Октонион 2: "; o2.print();
    
    Octonion sum = o1 + o2;
    cout << "Сумма: "; sum.print();
    
    return 0;
}
Соседние файлы в папке Лаба8