// Rational_numbers.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. #include #include "Rational.h" using namespace std; //решение void resh(Rational, Rational, Rational); //проверка класса void check(); int main() { Rational r = Rational(5.0/2.0),r2=Rational(3,6); cout << r2 << endl; cout << r << endl; //check(); //сделаны основные операции (минимум, который сдаётся до пятницы). К сожалению пока немного в тупике с решением. т.к. не знаю как перевести double //resh(Rational(2, 3), Rational(-1, 3), Rational(-1, 3)); //Rational a, b, c; //cout << "enter a=... b=... c=... \n"; //cin >> a >> b >> c; //resh(a, b, c); // } void check() { cout << "Hello World!\n"; Rational r, r2; cin >> r >> r2; cout << r << endl << endl << endl << r2 << endl << endl << endl; cout << "/" << endl; Rational eq = r / r2; cout << endl << endl << eq << endl << endl; cout << "*" << endl; eq = r * r2; cout << endl << endl << eq << endl << endl; cout << "+" << endl; eq = r + r2; cout << endl << endl << eq << endl << endl; cout << "-" << endl; eq = r - r2; cout << endl << endl << eq << endl << endl; bool tr = r > r2; cout << " > " << tr << endl; tr = r < r2; cout << " < " << tr << endl; tr = r >= r2; cout << " >= " << tr << endl; tr = r <= r2; cout << " <= " << tr << endl; tr = r == r2; cout << " == " << tr << endl; tr = r != r2; cout << " != " << tr << endl; cout << "rooot " << r.root() << endl; cout << "from int \n"; Rational k = Rational(4,3); int x = 2; Rational eq_k; cout << k << endl << endl; cout << "*" << x << endl; eq_k = k * x; cout << endl << endl << eq_k << endl << endl; cout << "+" << x << endl; eq_k = k + x; cout << endl << endl << eq_k << endl << endl; cout << "-" << x << endl; eq_k = k - x; cout << endl << endl << eq_k << endl << endl; cout << "/" << x << endl; eq_k = k / x; cout << endl << endl << eq_k << endl << endl; } void resh(Rational a, Rational b, Rational c) { Rational D, ac; Rational ans[2] ; ac = a * c; ac *= 4; cout << ac << endl; D = (b * b); //cout << D << endl; D = D-ac; if (D >= 0) { Rational x1 = b * (-1), x2 = b * (-1); cout << D << endl; x1 -=Rational( D.root()); x2 +=Rational( D.root()); x1 /= (a*2); x2 /= (a * 2); cout << "x1:\n" << x1 << endl << "x2:\n" << x2 << endl; } else { cout << "no rational anser \n"; } } //void main() { // double a = 1.616161; // a = 12.0 / 5.0; // //0x10000000000000 // unsigned long long int bits = *(unsigned long long int*)(&a); // bool sign = bits >> 63; // long long int mant = (bits & 0xFFFFFFFFFFFFF) | 0x10000000000000; // long long exp = (bits >> 52) & 0x7ff; // exp -= 1075; // // //cout << hex << sign << '\t' << hex << mant << '\t' << hex << exp << '\t' << dec << bits << '\t' << hex << bits << '\n'; // // long long t = ((long long int)1<<52); // //cout <