Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include<vector>
- using namespace std;
- class Fraction{
- long long x, y;
- char c;
- public:
- Fraction(long long _x=0, long long _y=1):x(_x), y(_y){}
- Fraction operator+(Fraction & n2){
- long long new_x =x*n2.y+y*n2.x;
- long long new_y=y*n2.y;
- Fraction new_num(new_x, new_y);
- return new_num;
- }
- Fraction operator+(long long);
- friend Fraction operator + (long long, const Fraction &);
- friend istream & operator>>(istream &, Fraction &);
- friend ostream & operator<<(ostream &, const Fraction &);
- void show();
- void read();
- };
- istream & operator>>(istream & inp, Fraction & f){
- char c;
- inp >> f.x>>c>>f.y;
- return inp;
- }
- ostream & operator<<(ostream & out, const Fraction & f){
- out << f.x<<"/"<<f.y;
- return out;
- }
- Fraction operator + (long long n, const Fraction & f){
- return (f.x + n*f.y, f.y);
- }
- Fraction Fraction::operator+(long long n){
- return Fraction(this->x+n*this->y, this->y);
- }
- void Fraction::read(){cin >> x >> c >> y;}
- void Fraction::show(){cout<<x<<"/"<<y;}
- void print(vector<Fraction> v, vector<Fraction> vy){
- if(v.size()<vy.size()){
- cout<<"YES";
- }
- else{
- cout<<"NO";
- }
- }
- void print(vector<int> v, vector<int> vy){
- if(v.size()<vy.size()){
- cout<<"YES";
- }
- else{
- cout<<"NO";
- }
- }
- void print(vector<char> v, vector<char> vy){
- if(v.size()<vy.size()){
- cout<<"YES";
- }
- else{
- cout<<"NO";
- }
- }
- template<typename A>
- void print(A v1, A v2) {
- if(v1>v2){
- cout << v1;
- }
- else{
- cout << v2;
- }
- }
- int main() {
- Fraction f;
- string choice;
- cin >> choice;
- if (choice == "INT") {
- int n, t;
- int ny, ty;
- vector<int> a;
- vector<int> ay;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> t;
- a.push_back(t);
- }
- cin >> ny;
- for (int i = 0; i < ny; i++) {
- cin >> ty;
- ay.push_back(ty);
- }
- print(a, ay);
- }
- else if (choice == "CHAR") {
- int yx;char yy;
- int yv;char yw;
- vector<char> yvv;
- vector<char> yww;
- cin >> yx;
- for (int i = 0; i < yx; i++) {
- cin >> yy;
- yvv.push_back(yy);
- }
- cin >> yv;
- for (int i = 0; i < yv; i++) {
- cin >> yw;
- yww.push_back(yw);
- }
- print(yvv, yww);
- }
- else if (choice == "FRACTION") {
- int x;Fraction y;
- int v;Fraction w;
- vector<Fraction> vv;
- vector<Fraction> ww;
- cin >> x;
- for (int i = 0; i < x; i++) {
- cin >> y;
- vv.push_back(y);
- }
- cin >> v;
- for (int i = 0; i < v; i++) {
- cin >> w;
- ww.push_back(w);
- }
- print(vv, ww);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement