#include "header.h"
#include <cstdio>
using namespace std;
int main()
{
printf("\nPROI - ZAD1\nNAZWISKO PROWADZACEGO\n\n\n");
int menu;
int a, b, c, d;
int menu2;
printf("Quantity of:\n[i 0]\n[0 -i] - is Afactor \n[0 1]\n[-1 0] - is Bfactor \n[0 i]\n[i 0] - is Cfactor");
printf("CHOOSE VALUE OF FACTORS\nA ");
scanf("%d", &a);
printf("B ");
scanf("%d", &b);
printf("C ");
scanf("%d", &c);
printf("D ");
scanf("%d", &d);
bool constructoron;
Quaternion *first = new Quaternion(a, b, c, d);
Quaternion second(a,b,c,d);
Quaternion third(a,b,c,d);
constructoron = false;
while (menu != 7)
{
if (constructoron = false)
printf("CHOOSE OPTION:\n(1) - ADDING\n(2) - SUBTRACTING\n(3) - MULTIPLYING\n(4) - MODULE\n(5) - CONSTRUCTOR/DESTRUCTOR ON\n(6) - END");
else
printf("CHOOSE OPTION:\n(1) - ADDING\n(2) - SUBTRACTING\n(3) - MULTIPLYING\n(4) - MODULE\n(5) - CONSTRUCTOR/DESTRUCTOR OFF\n(6) - END");
cin>>menu;
while (menu != 1 && menu != 2 && menu != 3 && menu != 4 && menu != 5 && menu != 6)
{
printf("INVALID VALUE!\n");
if (constructoron = false)
printf("CHOOSE OPTION:\n(1) - ADDING\n(2) - SUBTRACTING\n(3) - MULTIPLYING\n(4) - MODULE\n(5) - CONSTRUCTOR/DESTRUCTOR ON\n(6) - END");
else
printf("CHOOSE OPTION:\n(1) - ADDING\n(2) - SUBTRACTING\n(3) - MULTIPLYING\n(4) - MODULE\n(5) - CONSTRUCTOR/DESTRUCTOR OFF\n(6) - END");
cin>>menu;
}
switch(menu)
{
case 1:
printf("CHOOSE VALUE OF FACTORS OF QUATERNIONS WHICH YOU WILL ADD\nA ");
scanf("%d", &a);
printf("B ");
scanf("%d", &b);
printf("C ");
scanf("%d", &c);
printf("D ");
scanf("%d", &d);
second = Quaternion (a, b, c, d);
printf("CHOOSE OPTION:\n(1) - +\n(2) - += ");
scanf("%d", &menu2);
while (menu2 != 1 && menu2 != 2)
{
printf("INVALID VALUE!\n");
printf("CHOOSE OPTION:\n(1) - +\n(2) - += ");
scanf("%d", &menu2);
}
if (menu2 = 1)
{
third = *first + second;
cout<<third;
}
else
{
*first += second;
cout<<first;
}
break;
case 2:
printf("CHOOSE VALUE OF FACTORS OF QUATERNION WHICH YOU WILL SUBSTRACT\nA ");
scanf("%d", &a);
printf("B ");
scanf("%d", &b);
printf("C ");
scanf("%d", &c);
printf("D ");
scanf("%d", &d);
second = Quaternion (a, b, c, d);
printf("CHOOSE OPTION:\n(1) - -\n(2) - -= ");
scanf("%d", &menu2);
while (menu2 != 1 && menu2 != 2)
{
printf("INVALID VALUE!\n");
printf("CHOOSE OPTION:\n(1) - -\n(2) - -= ");
scanf("%d", &menu2);
}
if (menu2 = 1)
{
third = *first - second;
cout<<third;
}
else
{
*first -= second;
cout<<first;
}
break;
case 3:
printf("CHOOSE VALUE OF FACTORS OF QUATERNION WHICH YOU WANT TO MULTIPLY BY\nA ");
scanf("%d", &a);
printf("B ");
scanf("%d", &b);
printf("C ");
scanf("%d", &c);
printf("D ");
scanf("%d", &d);
second = Quaternion (a, b, c, d);
printf("CHOOSE OPTION:\n(1) - *\n(2) - *= ");
scanf("%d", &menu2);
while (menu2 != 1 && menu2 != 2)
{
printf("INVALID VALUE!\n");
printf("CHOOSE OPTION:\n(1) - *\n(2) - *= ");
scanf("%d", &menu2);
}
if (menu2 = 1)
{
third = *first * second;
cout<<third;
}
else
{
*first *= second;
cout<<first;
}
break;
case 4:
first module();
cout<<first;
break;
case 5:
if (constructoron = true)
constructoron = false;
else constructoron = true;
break;
case 6:
exit(1);
}
}
return 0;
}
I2luY2x1ZGUgImhlYWRlci5oIgojaW5jbHVkZSA8Y3N0ZGlvPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBwcmludGYoIlxuUFJPSSAtIFpBRDFcbk5BWldJU0tPIFBST1dBRFpBQ0VHT1xuX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AgICAgICAgc2NhbmYoIiVkIiwgJmMpOwogICAgICAgICAgICBwcmludGYoIkQgIik7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZkKTsKICAgICAgICAgICAgc2Vjb25kID0gUXVhdGVybmlvbiAoYSwgYiwgYywgZCk7CiAgICAgICAgICAgIHByaW50ZigiQ0hPT1NFIE9QVElPTjpcbigxKSAtICtcbigyKSAtICs9ICIpOwogICAgICAgICAgICBzY2FuZigiJWQiLCAmbWVudTIpOwogICAgICAgICAgICB3aGlsZSAobWVudTIgIT0gMSAmJiBtZW51MiAhPSAyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwcmludGYoIklOVkFMSUQgVkFMVUUhXG4iKTsKICAgICAgICAgICAgICAgIHByaW50ZigiQ0hPT1NFIE9QVElPTjpcbigxKSAtICtcbigyKSAtICs9ICIpOwogICAgICAgICAgICAgICAgc2NhbmYoIiVkIiwgJm1lbnUyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAobWVudTIgPSAxKQogICAgICAgICAgICB7CiAgICAgICAgICAgIHRoaXJkID0gKmZpcnN0ICsgc2Vjb25kOwogICAgICAgICAgICBjb3V0PDx0aGlyZDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgKmZpcnN0ICs9IHNlY29uZDsKICAgICAgICAgICAgY291dDw8Zmlyc3Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBwcmludGYoIkNIT09TRSBWQUxVRSBPRiBGQUNUT1JTIE9GIFFVQVRFUk5JT04gV0hJQ0ggWU9VIFdJTEwgU1VCU1RSQUNUXG5BICIpOwogICAgICAgICAgICBzY2FuZigiJWQiLCAmYSk7CiAgICAgICAgICAgIHByaW50ZigiQiAiKTsKICAgICAgICAgICAgc2NhbmYoIiVkIiwgJmIpOwogICAgICAgICAgICBwcmludGYoIkMgIik7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZjKTsKICAgICAgICAgICAgcHJpbnRmKCJEICIpOwogICAgICAgICAgICBzY2FuZigiJWQiLCAmZCk7CiAgICAgICAgICAgIHNlY29uZCA9IFF1YXRlcm5pb24gKGEsIGIsIGMsIGQpOwoKICAgICAgICAgICAgcHJpbnRmKCJDSE9PU0UgT1BUSU9OOlxuKDEpIC0gLVxuKDIpIC0gLT0gIik7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZtZW51Mik7CiAgICAgICAgICAgIHdoaWxlIChtZW51MiAhPSAxICYmIG1lbnUyICE9IDIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHByaW50ZigiSU5WQUxJRCBWQUxVRSFcbiIpOwogICAgICAgICAgICAgICAgcHJpbnRmKCJDSE9PU0UgT1BUSU9OOlxuKDEpIC0gLVxuKDIpIC0gLT0gIik7CiAgICAgICAgICAgICAgICBzY2FuZigiJWQiLCAmbWVudTIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtZW51MiA9IDEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgdGhpcmQgPSAqZmlyc3QgLSBzZWNvbmQ7CiAgICAgICAgICAgIGNvdXQ8PHRoaXJkOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAqZmlyc3QgLT0gc2Vjb25kOwogICAgICAgICAgICBjb3V0PDxmaXJzdDsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIHByaW50ZigiQ0hPT1NFIFZBTFVFIE9GIEZBQ1RPUlMgT0YgUVVBVEVSTklPTiBXSElDSCBZT1UgV0FOVCBUTyBNVUxUSVBMWSBCWVxuQSAiKTsKICAgICAgICAgICAgc2NhbmYoIiVkIiwgJmEpOwogICAgICAgICAgICBwcmludGYoIkIgIik7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZiKTsKICAgICAgICAgICAgcHJpbnRmKCJDICIpOwogICAgICAgICAgICBzY2FuZigiJWQiLCAmYyk7CiAgICAgICAgICAgIHByaW50ZigiRCAiKTsKICAgICAgICAgICAgc2NhbmYoIiVkIiwgJmQpOwogICAgICAgICAgICBzZWNvbmQgPSBRdWF0ZXJuaW9uIChhLCBiLCBjLCBkKTsKCiAgICAgICAgICAgIHByaW50ZigiQ0hPT1NFIE9QVElPTjpcbigxKSAtICpcbigyKSAtICo9ICIpOwogICAgICAgICAgICBzY2FuZigiJWQiLCAmbWVudTIpOwogICAgICAgICAgICB3aGlsZSAobWVudTIgIT0gMSAmJiBtZW51MiAhPSAyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwcmludGYoIklOVkFMSUQgVkFMVUUhXG4iKTsKICAgICAgICAgICAgICAgIHByaW50ZigiQ0hPT1NFIE9QVElPTjpcbigxKSAtICpcbigyKSAtICo9ICIpOwogICAgICAgICAgICAgICAgc2NhbmYoIiVkIiwgJm1lbnUyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAobWVudTIgPSAxKQogICAgICAgICAgICB7CiAgICAgICAgICAgIHRoaXJkID0gKmZpcnN0ICogc2Vjb25kOwogICAgICAgICAgICBjb3V0PDx0aGlyZDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgKmZpcnN0ICo9IHNlY29uZDsKICAgICAgICAgICAgY291dDw8Zmlyc3Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBmaXJzdCBtb2R1bGUoKTsKICAgICAgICAgICAgY291dDw8Zmlyc3Q7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNToKICAgICAgICAgICAgaWYgKGNvbnN0cnVjdG9yb24gPSB0cnVlKQogICAgICAgICAgICAgICAgY29uc3RydWN0b3JvbiA9IGZhbHNlOwogICAgICAgICAgICBlbHNlIGNvbnN0cnVjdG9yb24gPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGV4aXQoMSk7CiAgICAgICAgfQogICAgfQpyZXR1cm4gMDsKfQo=