Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #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<int> v){
- int max = v[0];
- for (int i = 0; i < v.size(); ++i) {
- if (v[i] > max) {
- max = v[i];
- }
- }
- cout << max << " ";
- }
- void printy(vector<char> v){
- char max = v[0];
- for (int i = 0; i < v.size(); ++i) {
- if (v[i] > max) {
- max = v[i];
- }
- }
- cout << max << " ";
- }
- void printyz(vector<Fraction> v){
- /* Fraction max = v[0];
- for (int i = 0; i < v.size(); ++i) {
- if (v[i] > max) {
- max = v[i];
- }
- cout << max << " ";
- }
- */
- }
- int main() {
- Fraction f;
- int n, t;
- vector<int> a;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> t;
- a.push_back(t);
- }
- int ny;char ty;
- vector<char> arr;
- cin >> ny;
- for (int i = 0; i < ny; i++) {
- cin >> ty;
- arr.push_back(ty);
- }
- int nyz;
- Fraction tyz;
- vector<Fraction> arrd;
- cin >> nyz;
- for (int i = 0; i < nyz; i++) {
- cin >> tyz;
- arrd.push_back(tyz);
- }
- print(a);cout<<endl;
- printy(arr);cout<<endl;
- printyz(arrd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement