Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.
A rational number can be represented using up to three parts: , , and a . The number will be represented in one of the following three ways:
public: Parser(string s): front(s.substr(0, s.find('.'))) { const string fill = "00000000"; auto dot = s.find('.'); if(dot == string::npos) { back = fill; } else { auto sof = s.find('('); if(sof == string::npos) { back = (s.substr(dot + 1) + fill).substr(0,8); } else { string nrPart = s.substr(dot+1, sof-dot-1); auto eof = s.find(')'); string rPart = s.substr(sof+1, eof-sof-1); back = nrPart; for(int i = 0; i < 8; i++) { back += rPart; } back = back.substr(0,8); } } }
booleq(int f, int b, int of, int ob){ b = b + 1; if(b == 100000000) b = 0, f += 1; return b == ob and f == of; }
booleq(Parser* other){ if(this->front == other->front andthis->back == other->back) returntrue; int b = stoi(back), ob = stoi(other->back); int f = stoi(front), of = stoi(other->front);