# data[].attributes.body
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class Student {
public:
string MaSV;
string HotenSV;
string Lop;
double Diem;

Student(string maSV, string hotenSV, string lop, double diem)
: MaSV(maSV), HotenSV(hotenSV), Lop(lop), Diem(diem) {}
};

class StudentManagement {
private:
vector<Student> students;

public:
void addStudent(const Student& student) {
students.push_back(student);
}

void deleteStudentByMaSV(const string& maSV) {
students.erase(remove_if(students.begin(), students.end(),
[&](const Student& student) { return student.MaSV == maSV; }),
students.end());
}

Student* findStudentByMaSV(const string& maSV) {
auto it = find_if(students.begin(), students.end(),
[&](const Student& student) { return student.MaSV == maSV; });

return it != students.end() ? &(*it) : nullptr;
}

vector<Student> listStudentsByClass(const string& lop) {
vector<Student> result;
for (const Student& student : students) {
if (student.Lop == lop) {
result.push_back(student);
}
}
return result;
}

void sortStudentsByIncreasingScore() {
sort(students.begin(), students.end(),
[](const Student& a, const Student& b) { return a.Diem < b.Diem; });
}
};

void displayMenu() {
cout << "1. Add new student\n"
<< "2. Delete student from the list\n"
<< "3. Find student by MaSV\n"
<< "4. List students by class\n"
<< "5. Sort student list by increasing score\n"
<< "6. Exit\n";
}

int main() {
StudentManagement studentManagement;
int choice;

do {
displayMenu();
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1: {
string maSV, hotenSV, lop;
double diem;
cout << "Enter MaSV: ";
cin >> maSV;
cout << "Enter HotenSV: ";
cin.ignore();
getline(cin, hotenSV);
cout << "Enter Lop: ";
cin >> lop;
cout << "Enter Diem: ";
cin >> diem;
studentManagement.addStudent(Student(maSV, hotenSV, lop, diem));
break;
}
case 2: {
string maSV;
cout << "Enter MaSV: ";
cin >> maSV;
studentManagement.deleteStudentByMaSV(maSV);
break;
}
case 3: {
string maSV;
cout << "Enter MaSV: ";
cin >> maSV;
Student* student = studentManagement.findStudentByMaSV(maSV);
if (student) {
cout << "MaSV: " << student->MaSV << ", HotenSV: " << student->HotenSV
<< ", Lop: " << student->Lop << ", Diem: " << student->Diem << '\n';
} else {
cout << "Student not found\n";
}
break;
}
case 4: {
string lop;
cout << "Enter Lop: ";
cin >> lop;
vector<Student> studentsByClass = studentManagement.listStudentsByClass(lop);
for (const Student& student : studentsByClass) {
cout << "MaSV: " << student.MaSV << ", HotenSV: " << student.HotenSV
<< ", Lop: " << student.Lop << ", Diem: " << student.Diem << '\n';
}
break;
}
case 5: {
studentManagement.sortStudentsByIncreasingScore();
cout << "Student list sorted by increasing score.\n";
break;
}
case 6: {
cout << "Exiting the program.\n";
break;
}
default: {
cout << "Invalid choice. Please try again.\n";
break;
}
}
} while (choice != 6);

return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class Student {
public:
    string MaSV;
    string HotenSV;
    string Lop;
    double Diem;

    Student(string maSV, string hotenSV, string lop, double diem)
        : MaSV(maSV), HotenSV(hotenSV), Lop(lop), Diem(diem) {}
};

class StudentManagement {
private:
    vector<Student> students;

public:
    void addStudent(const Student& student) {
        students.push_back(student);
    }

    void deleteStudentByMaSV(const string& maSV) {
        students.erase(remove_if(students.begin(), students.end(),
                                 [&](const Student& student) { return student.MaSV == maSV; }),
                       students.end());
    }

    Student* findStudentByMaSV(const string& maSV) {
        auto it = find_if(students.begin(), students.end(),
                          [&](const Student& student) { return student.MaSV == maSV; });

        return it != students.end() ? &(*it) : nullptr;
    }

    vector<Student> listStudentsByClass(const string& lop) {
        vector<Student> result;
        for (const Student& student : students) {
            if (student.Lop == lop) {
                result.push_back(student);
            }
        }
        return result;
    }

    void sortStudentsByIncreasingScore() {
        sort(students.begin(), students.end(),
             [](const Student& a, const Student& b) { return a.Diem < b.Diem; });
    }
};

void displayMenu() {
    cout << "1. Add new student\n"
         << "2. Delete student from the list\n"
         << "3. Find student by MaSV\n"
         << "4. List students by class\n"
         << "5. Sort student list by increasing score\n"
         << "6. Exit\n";
}

int main() {
    StudentManagement studentManagement;
    int choice;

    do {
        displayMenu();
        cout << "Enter your choice: ";
        cin >> choice;

        switch (choice) {
            case 1: {
                string maSV, hotenSV, lop;
                double diem;
                cout << "Enter MaSV: ";
                cin >> maSV;
                cout << "Enter HotenSV: ";
                cin.ignore();
                getline(cin, hotenSV);
                cout << "Enter Lop: ";
                cin >> lop;
                cout << "Enter Diem: ";
                cin >> diem;
                studentManagement.addStudent(Student(maSV, hotenSV, lop, diem));
                break;
            }
            case 2: {
                string maSV;
                cout << "Enter MaSV: ";
                cin >> maSV;
                studentManagement.deleteStudentByMaSV(maSV);
                break;
            }
            case 3: {
                string maSV;
                cout << "Enter MaSV: ";
                cin >> maSV;
                Student* student = studentManagement.findStudentByMaSV(maSV);
                if (student) {
                    cout << "MaSV: " << student->MaSV << ", HotenSV: " << student->HotenSV
                         << ", Lop: " << student->Lop << ", Diem: " << student->Diem << '\n';
                } else {
                    cout << "Student not found\n";
                }
                break;
            }
            case 4: {
                string lop;
                cout << "Enter Lop: ";
                cin >> lop;
                vector<Student> studentsByClass = studentManagement.listStudentsByClass(lop);
                for (const Student& student : studentsByClass) {
                    cout << "MaSV: " << student.MaSV << ", HotenSV: " << student.HotenSV
                         << ", Lop: " << student.Lop << ", Diem: " << student.Diem << '\n';
                }
                break;
            }
            case 5: {
                studentManagement.sortStudentsByIncreasingScore();
                cout << "Student list sorted by increasing score.\n";
                break;
            }
            case 6: {
                cout << "Exiting the program.\n";
                break;
            }
            default: {
                cout << "Invalid choice. Please try again.\n";
                break;
            }
        }
    } while (choice != 6);

    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class HinhTron
{
  double r;

public:
  HinhTron(double r) { this->r = r; }
  double nhapR(double r) { this->r = r; }
  double tinhChuVi()
  {
    return r * 3.14;
  }
  void inChuVi()
  {
    double C = tinhChuVi();
    cout << "Chu vi hinh tron : " << C << endl;
  }
  double tinhDienTich()
  {
    return r * r * 3.14;
  }
  double inDienTich()
  {
    double S = tinhDienTich();
    cout << "Dien tich hinh tron : " << S << endl;
  }
};

main() {
  HinhTron hc1(3);
  hc1.tinhChuVi();
  hc1.inChuVi();
  hc1.tinhDienTich();
  hc1.inDienTich();
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class ThiSinh
{
public:
  string sbd;
  float diemToan, diemHoa, diemLy;

public:
  ThiSinh() {}
  ThiSinh(string sbd, float diemToan, float diemHoa, float diemLy)
  {
    this->sbd = sbd;
    this->diemToan = diemToan;
    this->diemHoa = diemHoa;
    this->diemLy = diemLy;
  }

  void nhapThiSinh()
  {
    cout << "nhap so bao danh : ";
    cin >> sbd;
    cout << "nhap diem Toan : ";
    cin >> diemToan;
    cout << "nhap diem Hoa : ";
    cin >> diemHoa;
    cout << "nhap diem Ly : ";
    cin >> diemLy;
    cout << endl;
  }

  void xuatThiSinh() const
  {
    cout << " " << sbd << "\t" << diemToan << "\t" << diemHoa << " "
         << "\t"
         << " " << diemLy << "\t"
         << "  " << tongDiem() << endl;
  }

  float tongDiem() const
  {
    return diemToan + diemHoa + diemLy;
  }
};

void nhapDanhSachThiSinh(vector<ThiSinh> &ds)
{
  int n;
  cout << "nhap so luong thi sinh : ";
  cin >> n;
  ds.resize(n);
  for (int i = 0; i < n; i++)
  {
    cout << "nhap thi sinh thu " << i + 1 << endl;
    ds[i].nhapThiSinh();
  }
}

void xuatDanhSachThiSinh(const vector<ThiSinh> &ds)
{
  cout << "SBD"
       << "|Diem Toan"
       << "|Diem Hoa"
       << "|Diem Ly"
       << "|Tong Diem" << endl;
  for (const auto &ts : ds)
  {
    ts.xuatThiSinh();
  }
  cout << endl;
}

bool soSanhTangDan(const ThiSinh &ts1, const ThiSinh &ts2)
{
  return ts1.tongDiem() < ts2.tongDiem();
}

void sapXepTongDiemTangDan(vector<ThiSinh> &ds)
{
  sort(ds.begin(), ds.end(), soSanhTangDan);
}

vector<ThiSinh> thiSinhTongDiemCaoNhat(const vector<ThiSinh> &ds)
{
  vector<ThiSinh> result;
  ThiSinh tmax = ds[0];
  for (const auto &ts : ds)
  {
    if (tmax.tongDiem() < ts.tongDiem())
    {
      tmax = ts;
      result.clear();
      result.push_back(ts);
    }
    else if (tmax.tongDiem() == ts.tongDiem())
    {
      tmax = ts;
      result.push_back(ts);
    }
  }
  return result;
}

vector<ThiSinh> danhSachThiSinhTongDiemTren18(const vector<ThiSinh> &ds)
{
  vector<ThiSinh> res;
  for (auto &ts : ds)
  {
    if (ts.tongDiem() > 18)
    {
      res.push_back(ts);
    }
  }
  return res;
}

main()
{
  vector<ThiSinh> dsThiSinh;
  vector<ThiSinh> rs;
  nhapDanhSachThiSinh(dsThiSinh);
  cout << "1. Ham nhap va xuat thi sinh :" << endl;
  xuatDanhSachThiSinh(dsThiSinh);
  sapXepTongDiemTangDan(dsThiSinh);
  cout << "2. Danh sach tong diem tang dan :" << endl;
  xuatDanhSachThiSinh(dsThiSinh);
  cout << "3. Cac thi sinh co tong diem cao nhat :" << endl;
  rs = thiSinhTongDiemCaoNhat(dsThiSinh);
  xuatDanhSachThiSinh(rs);
  cout << "4. Thi sinh co tong diem tren 18 :" << endl;
  rs = danhSachThiSinhTongDiemTren18(dsThiSinh);
  xuatDanhSachThiSinh(rs);
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>

using namespace std;

class TamGiac
{
  float a, b, c;

public:
  TamGiac() { a = 2, b = 3, c = 4; }
  void nhapTamGiac()
  {
    float f, d, e;
    cout << "nhap do dai canh a : ";
    cin >> f;
    cout << "nhap do dai canh b : ";
    cin >> d;
    cout << "nhap do dai canh c : ";
    cin >> e;
    if (f < 0 || d < 0 || e < 0)
    {
      cout << "Cac canh trong tam giac phai lon hon 0!" << endl;
      nhapTamGiac();
    }
    if ((f + d > e) && (f + e > d) && (d + e > f))
    {
      a = f;
      b = d;
      c = e;
      cout << "Cac canh cua tam giac ban vua nhap la : a = " << a << ", b = " << b << ", c = " << c << endl;
    }
    else
    {
      cout << "3 canh vua nhap khong phai la 3 canh cua 1 tam giac." << endl;
      nhapTamGiac();
    }
  }
  float tinhDienTich()
  {
    float p = (a + b + c) / 2;
    return sqrt(p * (p - a) * (p - b) * (p - c));
  }
  string kieuTamGiac()
  {
    if ((a == b || a == c || b == c) && (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b))
    {
      return "Day la tam giac vuong can";
    }
    if (a == b || a == c || b == c)
    {
      return "Day la tam giac can.";
    }
    if (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b)
    {
      return "Day la tam giac vuong";
    }
    if (a == b && b == c)
    {
      return "Day la tam giac deu";
    }
    return "Day la tam giac thuong";
  }
  void hienThiThongTin()
  {
    cout << "Dien tich tam giac : " << tinhDienTich() << endl;
    cout << kieuTamGiac();
  }
};

main()
{
  TamGiac tg1;
  tg1.nhapTamGiac();
  tg1.hienThiThongTin();
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>

using namespace std;

class PhanSo
{
public:
  int ts, ms;

public:
  PhanSo() { ts = 0, ms = 1; };
  PhanSo(int ts, int ms) : ts(ts), ms(ms) {}
  void nhapPS()
  {
    cout << "nhap tu so : ";
    cin >> ts;
    cout << "nhap mau so : ";
    cin >> ms;
  }
  int UCLN()
  {
    int a = this->ts, b = this->ms;
    int tmp;
    while (b != 0)
    {
      tmp = a % b;
      a = b;
      b = tmp;
    }
    return a;
  }
  PhanSo toiGian()
  {
    int ucln = UCLN();
    return PhanSo(ts / ucln, ms / ucln);
  }
  int inPS()
  {
    cout << "(" << ts << " / " << ms << ")";
  }
  PhanSo operator+(PhanSo &ps2)
  {
    int tsTong = ts * ps2.ms + ps2.ts * ms;
    int msTong = ms * ps2.ms;

    return PhanSo(tsTong, msTong).toiGian();
  }
  PhanSo operator-(PhanSo &ps2)
  {
    int tsHieu = ts * ps2.ms - ps2.ts * ms;
    int msHieu = ms * ps2.ms;

    return PhanSo(tsHieu, msHieu).toiGian();
  }
  void soSanh(PhanSo &ps2)
  {
    int tsHieu = ts * ps2.ms - ps2.ts * ms;
    if (tsHieu < 0)
    {
      cout << ts << "/" << ms << " nho hon " << ps2.ts << "/" << ps2.ms << endl;
    }
    else
    {
      cout << ts << "/" << ms << " lon hon " << ps2.ts << "/" << ps2.ms << endl;
    }
  }
  PhanSo operator*(PhanSo &ps2)
  {
    return PhanSo(ts * ps2.ts, ms * ps2.ms).toiGian();
  }
  PhanSo operator/(PhanSo &ps2)
  {
    return PhanSo(ts * ps2.ms, ms * ps2.ts).toiGian();
  }
  void kiemTraToiGian()
  {
    int t = UCLN();
    if (t == 1)
    {
      cout << "Phan so da toi gian." << endl;
    }
    else
    {
      cout << "Phan so chua toi gian." << endl;
    }
  }
};

main()
{
  PhanSo ps1(1, 7);
  PhanSo ps2(1, 2);
  PhanSo ps3;
  ps3 = ps1 + ps2;
  ps3.inPS();
  cout << endl;
  ps3 = ps1 - ps2;
  ps3.inPS();
  cout << endl;
  ps3 = ps1 * ps2;
  ps3.inPS();
  cout << endl;
  ps3 = ps1 / ps2;
  ps3.inPS();
  cout << endl;
  ps3.kiemTraToiGian();
  ps2.soSanh(ps3);
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;

class SoPhuc
{
  int thuc, ao;

public:
  SoPhuc()
  {
    thuc = 0;
    ao = 0;
  }
  SoPhuc(int t, int a) { thuc = t, ao = a; }
  void nhapSoPhuc()
  {
    cout << "thuc: ";
    cin >> thuc;
    cout << "ao: ";
    cin >> ao;
  }
  void inSoPhuc()
  {
    cout << thuc << " + " << ao << "*j";
  }
  SoPhuc operator+(SoPhuc &p2)
  {
    int tThuc = thuc + p2.thuc;
    int aAo = ao + p2.ao;
    return SoPhuc(tThuc, aAo);
  }
  SoPhuc operator-(SoPhuc &p)
  {
    float t = thuc - p.thuc;
    float a = ao - p.ao;
    return SoPhuc(t, a);
  }
  SoPhuc operator*(SoPhuc &p)
  {
    float t = thuc * p.thuc - ao * p.ao;
    float a = ao * p.thuc + thuc * p.ao;
    return SoPhuc(t, a);
  }
};

main()
{
  SoPhuc p1(2, 3), p2(4, 5), p3;
  p3 = p1 + p2;
  cout << "Tong hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  p3 = p1 - p2;
  cout << "Hieu hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  p3 = p1 * p2;
  cout << "Tich hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;

class ThiSinh {
  private:
    string sbd;
    int diemToan;
	int diemHoa; 
	int diemLy;

  public:
    ThiSinh(string sbd = "", int diemToan = 0.0, int diemHoa = 0.0, int diemLy = 0.0)
      : sbd(sbd), diemToan(diemToan), diemHoa(diemHoa), diemLy(diemLy) { }

    void nhapThongTin() {
      cout << "Nhap so bao danh: ";
      cin >> sbd;
      cout << "Nhap diem Toan: ";
      cin >> diemToan;
      cout << "Nhap diem Hoa: ";
      cin >> diemHoa;
      cout << "Nhap diem Ly: ";
      cin >> diemLy;
    }

    void hienThiThongTin() {
      cout << "So bao danh: " << sbd << endl;
      cout << "Diem Toan: " << diemToan << endl;
      cout << "Diem Hoa: " << diemHoa << endl;
      cout << "Diem Ly: " << diemLy << endl;
      cout << "Tong diem: " << getTongDiem() << endl;
    }

    string getSBD() {
      return sbd;
    }

    float getTongDiem() {
      return diemToan + diemLy + diemHoa;
    }
};

int main() {
 int soLuongThiSinh;
  cout << "Nhap so luong thi sinh: ";
  cin >> soLuongThiSinh;
  }

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>

using namespace std;

class TamGiac {
  private:
    double a, b, c;

  public:
    TamGiac(double a = 0, double b = 0, double c = 0)
      : a(a), b(b), c(c) { }

    void nhapGiaTri() {
      do {
        cout << "Nhap gia tri cua 3 canh: ";
        cin >> a >> b >> c;
        if (a + b <= c || a + c <= b || b + c <= a) {
          cout << "Gia tri khong hop le! Vui long nhap lai." << endl;
        }
      } while (a + b <= c || a + c <= b || b + c <= a);
    }

    double tinhDienTich() {
      double p = (a + b + c) / 2;
      double S = sqrt(p * (p - a) * (p - b) * (p - c));
      return S;
    }

    bool laTamGiacCan() {
      return (a == b && a != c) || (a == c && a != b) || (b == c && b != a);
    }

    bool laTamGiacDeu() {
      return a == b && b == c;
    }

    bool laTamGiacVuong() {
      return a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a;
    }

    void hienThiThongTin() {
      double dienTich = tinhDienTich();
      cout << "Dien tich: " << dienTich << endl;
      if (laTamGiacCan()) {
        cout << "Tam giac can";
        if (laTamGiacVuong()) {
          cout << " va vuong" << endl;
        } else {
          cout << endl;
        }
      } else if (laTamGiacDeu()) {
        cout << "Tam giac deu" << endl;
      } else if (laTamGiacVuong()) {
        cout << "Tam giac vuong" << endl;
      } else {
        cout << "Tam giac thuong" << endl;
      }
    }
};

int main() {
  TamGiac tg;
  tg.nhapGiaTri();
  tg.hienThiThongTin();
  return 0;
}

# data[].attributes.attachment_link.readable_text
// Bai 1: Hien thi chu vi dien tich hinh tron 
#include <iostream> 
#include <math.h>
#define PI 3.14
using namespace std; 

class hinhtron
{
   private:
        float r;
   public:
      void nhap();
        float chuvi();
      	float dientich();
        void in();
};
// Dinh nghia ham thanh vien ben ngoai khai bao lop  
void hinhtron::nhap()
{
  cout<<"Nhap vao ban kinh:";
  cin>>r;
}

float hinhtron::chuvi()
{
  return (2*PI*r);
}

float hinhtron::dientich()
{
  return (PI*pow(r,2));
}

void hinhtron::in()
{
    cout<<"Chu vi hinh tron la:"<<chuvi()<<endl;
   cout<<"Dien tich hinh tron la:"<<dientich()<<endl;
}
int  main()
{
  hinhtron ht;
  ht.nhap();
  ht.in();
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class hinhTron{
	double bankinh;
	public:
		void nhap(){
			do{
				cout<<"Nhap ban kinh hinh tron: ";
				cin>>bankinh;
				if(bankinh<0)
				cout<<"Nhap lai ban kinh"<<endl;
			} while (bankinh <0);
		}  
		double ChuVi(){
			return 2*3.14*bankinh;
		}
		double DienTich(){
			return 3.14*bankinh*bankinh;
		}
		void hienthi(){
			cout<<"Ban kinh: "<<bankinh<<endl;
			cout<<"Chu vi: "<<ChuVi()<<endl;
			cout<<"Dien tich: "<<DienTich()<<endl;
		}
};

int main(){
	hinhTron ht;
	ht.nhap();
	ht.hienthi();
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream> 
#include <math.h>
using namespace std; 
class HinhTron{
    float r;
   public:
   	HinhTron(){
	   };
      void nhap(){
		  cout<<"Nhap vao ban kinh:";
		  cin>>r;
		}
    	float C(){
		  return (2*3.14*r);
		}
      	float S(){
		  return (3.14*pow(r,2));
		}
        void in(){
			cout<<"Chu vi hinh tron la: "<<C()<<endl;
			cout<<"Dien tich hinh tron la: "<<S()<<endl;
		}
};

int  main()
{
  HinhTron ht;
  ht.nhap();
  ht.in();
  return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <conio.h>
using namespace std;
class thisinh
{
		char sbd[20];
		float dtoan,dly,dhoa;
	public:
		void nhap(){
			cout<<"Nhap vao so bao danh :";
			cin>>sbd;
			cout<<"Nhap diem toan :";
			cin>>dtoan;
			cout<<"Nhap diem ly:";
			cin>>dly;
			cout<<"Nhap diem hoa:";
			cin>>dhoa;
		}
		void in(){
			cout<<"So bao danh "<<sbd;
			cout<<" Diem toan:"<<dtoan<<" Diem ly:"<<dly<<" Diem hoa:"<<dhoa;
			cout<<" Tong diem: "<<tdiem()<<endl;
		}
	float tdiem(){
		return(dtoan+dly+dhoa);
	}

};
class dsts
{
	int n;
	thisinh dsts[100];
	public:
		void nhapds(){
			cout<<"Nhap vao so luong thi sinh:";
			cin>>n;
			for(int i=0;i<n;i++)
			dsts[i].nhap();
			}
		void inds(){
			for(int i=0;i<n;i++)
			dsts[i].in();
			}
		void sapxep(){
			for(int i=0;i<n-1;i++)
			for(int j=i+1;j<n;j++)
			if(dsts[i].tdiem()>dsts[j].tdiem())
				{
					thisinh temp;
					temp= dsts[i];
					dsts[i]=dsts[j];
					dsts[j]=temp;
				}
			}
		void tdtren18(){
			for(int i=0;i<n;i++)
			if(dsts[i].tdiem()>18)
			dsts[i].in();
			}
};
int main() 
{
	dsts ds;
	ds.nhapds();
	cout<<"Sap xep danh sach cac thi sinh theo thu tu tang dan ve tong diem:"<<endl;
	ds.sapxep();
	ds.inds();
	cout<<"Danh sach cac thi sinh co tong diem tren 18 la:"<<endl;
	ds.tdtren18();
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<math.h>
using namespace std;
class TamGiac{
	float a,b,c;
	public:
		float S,p;
		TamGiac(){
		};
		void Nhap(){
			cout<<"Nhap vao 3 canh cua tam giac: ";
			cin>>a>>b>>c;
		}
		void Ktra(){
			if (a<b+c && b<a+c && c<a+b)
			{
				cout<<"Bo 3 so tren la tam giac";
				if (a*a==b*b+c*c || b*b==a*a+c*c || c*c== a*a+b*b)
					cout<<"\nDay la tam giac vuong";
				else if(a==b && b==c)
					cout<<"\nDay la tam giac deu";
				else if(a==b || a==c || b==c)
					cout<<"\nDay la tam giac can";
				else if(a*a > b*b+c*c || b*b > a*a+c*c || c*c > a*a+b*b)
					cout<<"\nDay la tam giac tu";
				else
				cout<<"\nDay la tam giac nhon";
				
			}
			else
				cout<<"\nBo 3 so tren khong la tam giac";
		}
		void In(){
			if (a<b+c && b<a+c && c<a+b)
			p = (a+b+c)/2;
			S = sqrt(p*(p-a)*(p-b)*(p-c));
			cout<<"Dien tich tam giac: " <<S;
		}
};
int main()
{
	TamGiac TG;
	TG.Nhap();
	TG.Ktra();
	TG.In();
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;
class soPhuc{
	double thuc, ao;
	public:
		soPhuc(){ thuc=0;ao=0;};
		soPhuc(double a, double b) { thuc=a; ao=b; };
		void Nhap(){
			cout<<"Nhap phan thuc: ";
			cin>>thuc;
			cout<<"Nhap phan ao: ";
			cin>>ao;
		}
		void In(){
			cout<<thuc<<"+"<<ao<<"i"<<endl;
		}
		soPhuc tong(soPhuc s);
		soPhuc hieu(soPhuc s);
		soPhuc tich(soPhuc s);
};
soPhuc soPhuc::tong(soPhuc s){
	double a = thuc + s.thuc;
	double b = ao + s.ao;
	return soPhuc(a,b);
}
soPhuc soPhuc::hieu(soPhuc s){
	double a = thuc - s.thuc;
	double b = ao - s.ao;
	return soPhuc(a,b);
}
soPhuc soPhuc::tich(soPhuc s){
	double a = (thuc * s.thuc) - (ao * s.ao);
	double b = (ao * s.thuc) + (thuc * s.ao);
	return soPhuc(a,b);
}
int main()
{
	soPhuc s1, s2;
	cout<<"Nhap so phuc thu 1:\n";
	s1.Nhap();
	cout<<"So phuc thu 1: ";
	s1.In();
	cout<<"Nhap so phuc thu 2:\n";
	s2.Nhap();
	cout<<"So phuc thu 2: ";
	s2.In();
	cout<<"Tong 2 so phuc: ";
	(s1.tong(s2)).In();
	cout<<"Hieu 2 so phuc: ";
	(s1.hieu(s2)).In();
	cout<<"Tich 2 so phuc: ";
	(s1.tich(s2)).In();
	return 0;
}

# data[].attributes.body
#include<iostream>
#include<cmath>
#include <string.h>
#include <vector>

using namespace std;
class Circle{
private:
float r;
public:
float pi = 3.14;
public:
void setR(){
cout<<"Nhap ban kinh r = ";
cin>>this->r;
}
float getR(){
return this->r;
}
float chuvi(){
return 2*this->r*this->pi;
}
float dientich(){
return this->pi*pow(this->r,2);
}
};
int main(){
Circle c;
c.setR();
cout<<"Chu vi tam giac la : "<<c.chuvi()<<endl;
cout<<"Dien tich tam giac la : "<<c.dientich();
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include <string.h>
#include <vector>
class ThiSinh {
	private:
	    string soBaoDanh;
	    double diemToan;
	    double diemHoa;
	    double diemLy;
	public:
		ThiSinh(){};
	    ThiSinh(string soBaoDanh, double diemToan, double diemHoa, double diemLy) {
	        this->soBaoDanh = soBaoDanh;
	        this->diemToan = diemToan;
	        this->diemHoa = diemHoa;
	        this->diemLy = diemLy;
	    }
	    float tongdiem(){
	    	return this->diemToan + this->diemHoa + this->diemLy;
		}
	    string getSoBaoDanh() {
	        return soBaoDanh;
	    }
	    double getDiemToan() {
	        return diemToan;
	    }
	    double getDiemHoa() {
	        return diemHoa;
	    }
	    double getDiemLy() {
	        return diemLy;
	    }
};

int main() {
    int n,a;
    vector<ThiSinh> sv;
	while(1){
		cout<<"----------------Menu---------------"<<endl;
		cout<<"1 . Nhap so luong thi sinh\n";
		cout<<"2 . Hien thi danh sach\n";
		cout<<"3 . Thi sinh co diem cao nhat\n";
		cout<<"4 . Hien thi danh sach sinh vien co tong diem lon hon 18\n";
		cout<<"5 . Sap xep danh sach sinh vien \n";
		cout<<"-----------------------------------"<<endl;
		cout<<"Nhap lua chon : "; 
		
		int select ; cin>>select;
		if(select == 1 ){
			cout << "Nhap so luong thi sinh: ";
    		cin >> n;
			for (int i = 0; i < n; i++) {
		        string soBaoDanh;
		        double diemToan, diemHoa, diemLy;
		
		        cout << "Nhap so bao danh: ";
		        cin >> soBaoDanh;
		        cout << "Nhap diem toan: ";
		        cin >> diemToan;
		        cout << "Nhap diem hoa: ";
		        cin >> diemHoa;
		        cout << "Nhap diem ly: ";
		        cin >> diemLy;
		
		        ThiSinh ts(soBaoDanh, diemToan, diemHoa, diemLy);
		        sv.push_back(ts);
    		}
		}
		else if(select ==  2){
			cout << "---------Danh sach thi sinh ---------- :\n";
		    for (int i = 0; i < sv.size(); i++) {
		     	cout << "------Thi sinh "<<i+1<<" ------ : "<<endl;
		        cout << "So bao danh: " << sv[i].getSoBaoDanh()<<endl;
		        cout << "Diem toan: " << sv[i].getDiemToan()<<endl;
		        cout << "Diem hoa: " << sv[i].getDiemHoa()<<endl;
		        cout << "Diem ly: " << sv[i].getDiemLy()<<endl;
		        cout<<"Tong diem : "<<sv[i].tongdiem()<<endl;
		        cout<<"---------------------------------------";
		        cout <<endl;
		    }
		}
		else if(select ==  3){
		    int max = 0;
			for (int i = 0; i < sv.size(); i++) {
		    	if(max < sv[i].tongdiem()){
		    		max = sv[i].tongdiem();
				}
		    }   
		    for(int i = 0;i<sv.size();i++){
		    	if(sv[i].tongdiem() == max) {
		    		cout << "So bao danh: " << sv[i].getSoBaoDanh() <<" co tong diem lon nhat "<< std::endl;
		    		break;
				}
			}
		}
		else if(select ==  4){
			cout << "--------Danh sach thi sinh co tong diem lon hon 18 la ------- :\n";
		    for (int i = 0; i < sv.size(); i++) {
		    	if(sv[i].tongdiem() > 18 ){
			     	cout << "-----Thi sinh ------- :" << i+1 << std::endl;
			        cout << "So bao danh: " << sv[i].getSoBaoDanh() << std::endl;
			        cout << "Diem toan: " << sv[i].getDiemToan() << std::endl;
			        cout << "Diem hoa: " << sv[i].getDiemHoa() << std::endl;
			        cout << "Diem ly: " << sv[i].getDiemLy() << std::endl;
			        cout<<"Tong diem : "<<sv[i].tongdiem()<<endl;
			        cout<<"-----------------------------------------------------------";
			        cout <<endl;
				}
		    }
		}
		else if(select == 5){
			ThiSinh ts;
			for(int i = 0;i<sv.size() - 1;i++){
				for(int j = i+1 ;j<sv.size();j++){
					if(sv[i].tongdiem() < sv[j].tongdiem()){
						ts = sv[i]; 
						sv[i] = sv[j];
						sv[j] = ts;
					}
				}
			}
			cout<<"Da sap xep xong vui long an 2 de hien thi";
		}
	}
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include <string.h>
#include <vector>
class tamGiac{
	float a,b,c;
	public :
		void nhap(){
			cout<<"Nhap 3 canh cua 1 tam giac : ";
			cin>>this->a>>this->b>>this->c;
		}
		bool check(){
			if((a >= b + c || b >= a + c || c >= a + b) && (a >0 && b> 0 && c>0)){
				return false; 
			}
			return true;
		}
		float chuvi() {
 			return a + b + c;
		}
		float dientich() {
 			float p = chuvi() / 2.0;
 			return sqrt(p*(p - a)*(p - b)*(p - c));
		}
		void in(){
			cout<<"Dien tich cua tam giac la : "<<dientich();
		}		
		void ktratamgiac(){
			bool check = false;
			if(this->check()){
				cout<<"3 canh k la 1 tam giac";
				return ;
			}
			if(a == b && b == c){
				cout<<"La tam giac deu.";
				check = true;
			}
			else if(a == b || b == c || a== c){
				cout<<"La tam giac can.";
				check == true;
			}
			else if((pow(a,2) == (pow(b,2) + pow(c,2)) || pow(c,2) == (pow(a,2) + pow(b,2))
				|| pow(b,2) == (pow(a,2) + pow(c,2))) && (a == b && b == c)){
				cout<<"La tam giac vuong can.";	
				check = true;
			}
			else if(pow(a,2) == (pow(b,2) + pow(c,2)) || pow(c,2) == (pow(a,2) + pow(b,2))
				|| pow(b,2) == (pow(a,2) + pow(c,2))){
					cout<<"La tam giac vuong";
					check = true;
				}
			else if(!check){
				cout<<"La tam giac thuong.";
			}
		}
};
int main(){
	tamGiac tg;
	tg.nhap();
	tg.ktratamgiac();
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
using namespace std;
class phanSo{
	float ts,ms;
	public:
		phanSo(){};
		phanSo(float _ts,float _ms){
			this->ts = _ts;
			this->ms = _ms;
		};
		void nhap(){
			cout<<"nhap phan so";
			cin>>ts>>ms;
		}
		int gcd(int ts, int ms) {
		    if (ms == 0) {
		        return ts;
		    }
		    return gcd(ms, ts % ms);
		}

		void in(){
			if(ts == ms ){
				cout<<"phan so do la : "<<ts;
			}
			else if(ts == 0){
				cout<<"Phan so do la : "<<ts;
			}
			else{
				cout<<"phan so do la : "<<ts<<"/"<<ms;
			}
		}
		bool checkToiGian(){
			int value = gcd(ts,ms);
			return value == 1; 
		}
		const phanSo tich(const phanSo &ps);
		const phanSo thuong(const phanSo &ps);
		const phanSo tong(const phanSo &ps);
		const phanSo hieu(const phanSo &ps);
		const phanSo sosanh(const phanSo &ps);
		
};
const phanSo phanSo::sosanh(const phanSo &ps){
	int _ts = ts*ps.ms;
	int _ts2 = ms*ps.ts;

	(_ts > _ts2) ? cout<<"phan so dau lon hon " : cout<<"phan so sau lon hon";
}
const phanSo phanSo::tong(const phanSo &ps){
	int _ts = ts*ps.ms + ms*ps.ts;
	int _ms = ms*ps.ms;
	int gcdValue = gcd(_ts, _ms);
	
    _ts /= gcdValue;
    _ms /= gcdValue;
	return phanSo(_ts,_ms);
}
const phanSo phanSo::hieu(const phanSo &ps){
	int _ts = ts*ps.ms - ms*ps.ts;
	int _ms = ms*ps.ms;
	int gcdValue = gcd(_ts, _ms);
	
    _ts /= gcdValue;
    _ms /= gcdValue;
	return phanSo(_ts,_ms);
}
const phanSo phanSo::tich(const phanSo &ps){
	int _ts = ts*ps.ts;
	int _ms = ms*ps.ms;
	int gcdValue = gcd(_ts, _ms);
	
    _ts /= gcdValue;
    _ms /= gcdValue;
	return phanSo(_ts,_ms);
}
const phanSo phanSo::thuong(const phanSo &ps){
	int _ts = ts*ps.ms;
	int _ms = ms*ps.ts;
	int gcdValue = gcd(_ts, _ms);
	
    _ts /= gcdValue;
    _ms /= gcdValue;
	return phanSo(_ts,_ms);
}
int main(){
	phanSo a(1,2), b(1,2),c;
	if(a.checkToiGian()){
		cout<<"Phan so da toi gian .";
	}
	else{
		cout<<"Phan so chua toi gian .";
	}
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
using namespace std;
class soPhuc{
	float thuc,ao;
	public:
		soPhuc(){};
		soPhuc(float _thuc,float _ao){
			this->thuc = _thuc;
			this->ao = _ao;
		};
		void nhap(){
			cout<<"nhap so phuc";
			cin>>thuc>>ao;
		}
		
		void in(){
			cout<<"so phuc do la : "<<thuc<<" +("<<ao<<")*j";
		}
		const soPhuc tich(const soPhuc &sp);
		const soPhuc tong(const soPhuc &sp);
		const soPhuc hieu(const soPhuc &sp);
};
const soPhuc soPhuc::tong(const soPhuc &sp){
	int _thuc = thuc + sp.thuc;
	int _ao = ao + sp.ao;
	return soPhuc(_thuc,_ao);
}
const soPhuc soPhuc::hieu(const soPhuc &sp){
	int _thuc = thuc + sp.thuc;
	int _ao = - (ao + sp.ao);
	return soPhuc(_thuc,_ao);
}
const soPhuc soPhuc::tich(const soPhuc &sp){
	int _thuc = thuc*sp.thuc - ao *sp.ao;
	int _ao = ao*sp.thuc + thuc *sp.ao;
	return soPhuc(_thuc,_ao);
}
int main(){
	soPhuc s(2,3), s1(1,2),s2;
	s2 = s.tich(s1);
	s2.in();
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
class hinhTron
{
private:
    int r;
public:
    hinhTron(){};
    void input(){
        cout<<"nhap ban kinh hinh tron :"; cin>>r;
    };
    void output(){
        cout<<"Dt = "<<r*r*3.1415;
        cout<<"\nChu vi = "<<r*2*3.1415;
    };

};

int main(){
    hinhTron r;
    r.input();
    r.output();
    return 0 ;
} // namespace std;

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include<string>
using namespace std;
class Sinhvien
{
private:
    int stt,n;
    float dt,dl,dh;
    Sinhvien *sv;

public:
    Sinhvien(/* args */){};
    void getsbd(int sbd){stt =sbd;}
    void getDiem(float t,float l,float h);
    float Tong(){ return (dt+dl+dh);}
    void sepxep();
    void top18();
    void maxtong();
    void input();
    void output();
};
void Sinhvien::getDiem(float t,float l,float h){
    dt=t;
    dl=l;
    dh=h;
    return;
}
void Sinhvien::top18(){
    cout<<"danh sach sinh vien tren 18 diem"<< endl;
    for (int i = 0; i < n; i++)
    {
        if (sv[i].Tong()>18)
        {
            sv[i].output();
        }
        
    }
}
void Sinhvien::sepxep(){
    cout<<"danh sach sau khi sap xep"<<endl;
    for (int i = 0; i < n ; i++)
    {
        for (int  j = 0; j < i; j++)
        {
                if (sv[i].Tong()>sv[j].Tong())
                {
                    Sinhvien sx;
                    sx =sv[i];
                    sv[i]=sv[j];
                    sv[j]=sx;
                }
                
        }
        
    }
    for (int i = 0; i < n; i++)
    {
            sv[i].output();
    }
}
void Sinhvien::maxtong(){
    cout<<"Sinh vien co diem cao nhat la: "<<endl;
    Sinhvien max;
    for (int i = 0; i < n; i++)
    {   
        if (sv[i].Tong() > max.Tong())
        {
            max = sv[i];
        }
        
    }
    max.output();
}

void Sinhvien::input(){
    cout<<"nhap so sinh vien = ";cin>>n;
    sv = new Sinhvien[n];
    for (int i = 0; i < n; i++)
    {
        int sbd;
        string name;
        float t, l, h;
        cout << "Sinh vien thu " << i+1 << ": " <<endl;  
        cout << "\n So bao danh: ";cin>>sbd;
        sv[i].getsbd(sbd);
        cout << "\nNhap diem Toan: ";
        cin >> t;
        cout << "Nhap diem Ly: ";
        cin >> l;
        cout << "Nhap diem Hoa: ";
        cin >>h;
        sv[i].getDiem(t,l,h);   
    }
    for (int i = 0; i < n; i++)
    {
            sv[i].output();
    }
}
void Sinhvien::output(){
    cout<<"So bao danh "<<stt;
	cout<<" Diem toan:"<<dt<<" Diem ly:"<<dl<<" Diem hoa:"<<dh;
	cout<<" Tong diem: "<<Tong()<<endl;
}

int main(){
    Sinhvien sv;
    sv.input();
    sv.sepxep();
    sv.top18();
    sv.maxtong();
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <math.h>
using namespace std;

class tamGiac
{
private:
    int a,b,c;
public:
    void check();
    void S();
    void input();
    void output();
};
void tamGiac::input(){
    cout<<"nhap canh A:";cin>>a;
     cout<<"nhap canh b :";cin>>b;
      cout<<"nhap canh c :";cin>>c;
}
void tamGiac::check(){
    while (a + b <= c || a + c <= b ||  b + c <= a)
    {
        cout<<"Tam giac ko hop le! moi nhap lai!"<<endl;
            cout<<"nhap canh A:";cin>>a;
            cout<<"nhap canh b :";cin>>b;
            cout<<"nhap canh c :";cin>>c;
    }
    cout<<"Day la tam giac :";
    if ((a == b) && (b == c))
    {
        cout<<"Đều !";
    }else
    // {
    //     if (a * a + b * b == c * c || a * c + c * c == b * b || b * b + c * c == a * c)
    //     {
    //         cout<<"vuông !";
    //     }
    //     else (a == b || a == c || b == c);
    //     {
    //         cout<<"Cân !";
    //     }
    // };

    if(a == b || a == c || b == c)
		{
			printf("\nTam giac can");
		}
		
		else if(a * a + b * b == c * c || a * c + c * c == b * b || b * b + c * c == a * c)
		{
			printf("\nTam giac vuong");
		}
		else
		{
			printf("\nTam giac thuong");
        }
}
void tamGiac::S(){
    double p;
    p =(a+b+c)/2; 
    cout<<"\nDien tich tam giac la :"<<sqrt(p*(p-a)*(p-b)*(p-c));;
}
void tamGiac::output(){
    tamGiac s;
    s.check();
    s.S();
}
int main(){
    tamGiac q;
    q.input();
    q.output();
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class phanso{
private:
    int ts,ms;
public:
    phanso(){}
    phanso(int t,int m){t=ts;m=ms;}
    int t(){return ts;}
    int m(){return ms;}
    void input();
    void output();
    float t_h_t_t(phanso ane);
    phanso toiGian(phanso &ps);
    void sosanh();
    int UCLN(int a, int b){
        int tmp;
        while(b != 0) {
            tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }
    friend phanso tich(phanso &ps,phanso &ps1);
    friend phanso thuong(phanso &ps,phanso &ps1);

};
void phanso::input(){
    cout<<"nhap phan so :";
    cin>>ts;cout<<"/";cin>>ms;
}
float phanso::t_h_t_t(phanso ane){
    //tong
    if (this->ms == ane.ms)
    {
        cout<<"\ntong = "<<(this->ts+ane.ts)<<"/"<<ms;
    }
    if (this->ms != ane.ms)
    {
        int t,m;
        t= (this->ts*ane.ms)+(this->ms*ane.ts);
        m= this->ms*ane.ms;
        cout<<"\ntong ="<<t<<"/"<<m; 
    }
    //Hieu
    if (this->ms == ane.ms)
    {
        cout<<"\nHieu = "<<(this->ts-ane.ts)<<"/"<<ms;
    }
    if (this->ms != ane.ms)
    {
        int t,m;
        t= (this->ts*ane.ms)-(this->ms*ane.ts);
        m= this->ms*ane.ms;
        cout<<"\nhieu ="<<t<<"/"<<m; 
    }

    // //tich
    // cout<<"\nTich = "<<(this->ts*ane.ts)<<"/"<<(this->ms*ane.ms);
    // //thuong
    // cout<<"\nThuong = "<<(this->ts*ane.ms)<<"/"<<(this->ms*ane.ts);
}
phanso tich(phanso &ps ,phanso &ps1){
    // phanso tmp;
    int tts=ps.ts*ps1.ts;
    int tms=ps.ms*ps1.ms;
    return phanso(tts,tms);
}
phanso thuong(phanso &ps ,phanso &ps1){
    int tts=ps.ts*ps1.ms;
    int tms=ps.ms*ps1.ts;
    return phanso(tts,tms);
}

 phanso toiGian(phanso &ps){
    int tsTMP = ps.t()/UCLN(ps.t(),ps.m());
    int msTMP = ps.m()/UCLN(ps.t(), ps.m());
    if (msTMP != 1)
    {
        if (msTMP < 0){
            msTMP = msTMP*-1;
            tsTMP = tsTMP*-1;
        }
        return phanso(tsTMP,msTMP);
    }
    else{
        return phanso(tsTMP, msTMP);
    }  
}
void phanso::output(){
    cout<<"\nphan so :"<<ts<<"/"<<ms;
}

int main(){
    phanso a,b,kq;
    a.input();
    b.input();
    a.output();
    b.output();
    a.t_h_t_t(b);
    kq=tich(a,b);
    cout<<"\nTich 2 phan so la: "<<kq.t()<<"/"<<kq.m();
    kq=thuong(a,b);
    cout<<"\nThuong 2 phan so la: "<<kq.t()<<"/"<<kq.m();

return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class soPhuc
{
private:
    int thuc,ao;
public:
    soPhuc(){}
    soPhuc(int t,int a){t=thuc;a=ao;}
    void input(){
        cout<<"nhap so thuc";cin>>thuc;cout<<endl;
        cout<<"nhap so ao";cin>>ao;cout<<endl;
    }
    void output(){
        cout<<"So: "<<thuc<<"+"<<ao<<"i";
    }
    soPhuc tong(soPhuc &t){
        int ta= thuc +t.thuc;
        int a= ao+t.ao;
        return soPhuc(ta,a);
    }
    soPhuc hieu(soPhuc t){
        int ta = thuc-t.thuc;
        int a= ao-t.ao;
        return soPhuc(ta,a);
    }
    soPhuc tich(soPhuc t){
        int ta = (thuc*t.thuc-ao-t.ao);
        int a= (ao*t.thuc+thuc*t.ao);
        return soPhuc(ta,a);
    }
};
int main(){
    soPhuc t1,t2,kq,kq1,kq2;
    t1.input();
    t2.input();
    t1.output();
    t2.output();
    kq = t1.tong(t2);
    cout<<"\ntong =";kq.output();
        kq = t1.hieu(t2);
            cout<<"\nhieu =";kq1.output();
            kq = t1.tich(t2);
                cout<<"\ntich =";kq2.output();
    
   
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <math.h>
using namespace std;

class Hinhtron{
        double pi = 3.14, r;
    public: 
        void nhap(){
        do{
            cout << "Nhap ban kinh: ";
            cin >> r;
            if (r <= 0){
                cout <<"Ban kinh phai > 0. Vui long nhap lai! " << endl;
            }
            else {
            cout << "Chu vi hinh tron: " <<  chuvi(pi,r) << endl;
            cout << "Dien tich hinh tron: " << dientich(pi,r) <<endl; 
        } 
        } 
        while(r <= 0);

        }

        double chuvi(double pi, double r) {
        return (2 * pi * r);
        }

        double dientich(double pi, double r) {
        return (pi * r * r);
        }

};

int main () {
    Hinhtron tinhtoan;
    tinhtoan.nhap();
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class Thisinh{
	int sobaodanh, diemtoan, diemhoa, diemly;

public:
	void nhap(class Thisinh *ts){
		cout<<"Nhap thong tin thi sinh: "<<endl;
		cout<<"So Bao Danh: ";	cin>>(*ts).sobaodanh;
		cout<<"Diem Toan: "; cin>>(*ts).diemtoan;
		cout<<"Diem Hoa: ";	cin>>(*ts).diemhoa;
		cout<<"Diem Ly: ";	cin>>(*ts).diemly;
		cin.ignore();
	}
	
	int TongDiem (int diemtoan, int diemhoa, int diemly){
			int tongdiem = 0;
			tongdiem = diemtoan + diemhoa + diemly;
			return tongdiem;
	}
	void in(class Thisinh ts){
		cout<<"Thong tin thi sinh: "<<endl;
		cout<<"So Bao Danh: "<<ts.sobaodanh<<endl;
		cout<<"Diem Toan: "<<ts.diemtoan<<endl;
		cout<<"Diem Hoa: "<<ts.diemhoa<<endl;
		cout<<"Diem Ly: "<<ts.diemly<<endl;
		cout<<"Tong diem 3 mon: "<<TongDiem(ts.diemtoan, ts.diemhoa, ts.diemly);
	}
		
	void Sapxep(class Thisinh ds[], int sots, int TongDiem()){
		for(int i=0; i<sots -1; i++){
			for (int j=i + 1; j< sots; j++ ){
				if(ds[i].tongdiem)
				
			}
		}
}

};
int main(){
	Thisinh ts;
	ts.nhap(&ts);
	ts.in(ts);
	
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <math.h>
using namespace std;

class TamGiac{
		double a, b, c;
	public:
		void nhap(){
			cout << "Nhap cac canh a, b, c lan luot: " << endl;
			cin >> a >> b >> c;
		}
		
		int KiemTraTamGiac(double a, double b, double c){
		if( a<b+c && b<a+c && c<a+b ){
 			if( a*a==b*b+c*c || b*b==a*a+c*c || c*c== a*a+b*b)
 				cout<<"Day la tam giac vuong";
 				//return 1;
 			else if(a==b && b==c)
 				cout<<"Day la tam giac deu";
 				//return 2;
 			else if(a==b || a==c || b==c)
 				cout<<"Day la tam giac can";
 				//return 3;
 			else if(a*a > b*b+c*c || b*b > a*a+c*c || c*c > a*a+b*b) 
 				cout<<"Day la tam giac tu";
 				//return 4;
 			else
 				cout<<"Day la tam giac nhon";
 				//return 5
 		}
 		else
  				cout<<"Ba canh a, b, c khong phai la ba canh cua mot tam giac";
  				//return 6;
		}
	
		double Chuvi(double a, double b, double c) {
			return a + b + c;
		}
	
		double Dientich(double a, double b, double c) {
			double p = Chuvi(a, b, c) / 2;
			return sqrt(p * (p - a) * (p - b) * (p - c));
		}
		
		void in() {
			cout << "Dien tich tam giac: " << Dientich(a, b, c)<<endl;
			KiemTraTamGiac(a,b,c);
		}
};


int main() {
	double a, b, c;
	TamGiac canh;
	canh.nhap();
	canh.in();
	return 0;
}


# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class PS{
	double TuSo, MauSo;
public:
	void Nhap(PS& x){
		do{
			cout<<"Nhap ts: ";	cin>>x.TuSo;
			cout<<"Nhap ms: ";	cin>>x.MauSo;
			if(x.MauSo == 0){
				cout<<"Yeu cau nhap lai!"<<endl;
			}
		}while(x.MauSo==0);		
	}
	
	void QuyDong(PS x, PS y, int& a, int& b, int& MauChung){
	a = x.TuSo * y.MauSo;
	b = y.TuSo * x.MauSo;
	MauChung = x.MauSo * y.MauSo;
	}
	
	int USCLN(int m, int n){
	if (m % n == 0)
		return n;
	return USCLN(n, m % n);
	
	}
	void RutGon(int a, int b){
	int i = USCLN(a, b);
	a = a / i;
	b = b / i;
	if ((a < 0 && b < 0) || (a > 0 && b < 0))
	{
		a = -a;
		b = -b;
	}
	if (a % b == 0) cout << a / b <<endl;
	else cout << a << "/" << b <<endl;
	}

	void Xuat(PS x, PS y,int &a,int &b,int &MauChung){
	QuyDong(x, y, a, b, MauChung);
	cout << "Tong 2 phan so = ";
	RutGon(a + b, MauChung);
	cout << "Hieu 2 phan so = ";
	RutGon(a - b, MauChung);
	cout << "Tich 2 phan so = ";
	RutGon(x.TuSo * y.TuSo, x.MauSo * y.MauSo);
	cout << "Thuong 2 phan so = ";
	RutGon(x.TuSo * y.MauSo, y.TuSo * x.MauSo);
	}

};

int main(){
	PS PS1, PS2, A;
	int a, b, MauChung;
	cout << "Nhap phan so thu nhat:" <<endl;
	PS1.Nhap(PS1);
	cout << "Nhap phan so thu hai:" <<endl;
	PS2.Nhap(PS2);
	A.Xuat(PS1, PS2, a, b, MauChung);
	return 0;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;

class soPhuc {
private:
    float thuc, ao;

public:
    soPhuc() : thuc(0), ao(0) {}

    soPhuc(float t, float a) : thuc(t), ao(a) {}

    void nhap() {
        cout << "Nhap phan thuc: ";
        cin >> thuc;
        cout << "Nhap phan ao: ";
        cin >> ao;
    }

    void in() {
        cout << thuc << " + " << ao << "i";
    }

    friend soPhuc operator+(const soPhuc& a, const soPhuc& b) {
        soPhuc c;
        c.thuc = a.thuc + b.thuc;
        c.ao = a.ao + b.ao;
        return c;
    }

    friend soPhuc operator-(const soPhuc& a, const soPhuc& b) {
        soPhuc c;
        c.thuc = a.thuc - b.thuc;
        c.ao = a.ao - b.ao;
        return c;
    }

    friend soPhuc operator*(const soPhuc& a, const soPhuc& b) {
        soPhuc c;
        c.thuc = a.thuc * b.thuc - a.ao * b.ao;
        c.ao = a.thuc * b.ao + a.ao * b.thuc;
        return c;
    }

    friend ostream& operator<<(ostream& os, const soPhuc& sp) {
        os << sp.thuc << " + " << sp.ao << "i";
        return os;
    }

    friend istream& operator>>(istream& is, soPhuc& sp) {
        cout << "Nhap phan thuc: ";
        is >> sp.thuc;
        cout << "Nhap phan ao: ";
        is >> sp.ao;
        return is;
    }
};

int main() {
    soPhuc sp1, sp2;
    cout << "Nhap so phuc thu 1:\n";
    cin >> sp1;
    cout << "Nhap so phuc thu 2:\n";
    cin >> sp2;

    cout << "So phuc thu 1: " << sp1 << endl;
    cout << "So phuc thu 2: " << sp2 << endl;

    cout << "Ket qua phep cong: " << sp1 + sp2 << endl;
    cout << "Ket qua phep tru: " << sp1 - sp2 << endl;
    cout << "Ket qua phep nhan: " << sp1 * sp2 << endl;

    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
	
		int ucln(int a, int b) {
			if (b == 0) return a;
			return ucln(b, a%b);
		}
		
		void toiGianPhanSo() {
			int uc = ucln(ts, ms);
			ts /= uc;
			ms /= uc;
		}
	
		friend PhanSo operator+(const PhanSo& a, const PhanSo& b) {  // khai bao ham ban xai phep cong 
	        PhanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator-(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep tru
	        PhanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend PhanSo operator*(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep nhan 
	        PhanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator/(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep chia 
	        PhanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend bool operator==(const PhanSo& a, const PhanSo& b) {  // kiem tra so sanh 2 phan so 
	        return a.ts * b.ms == a.ms * b.ts;
	    }

};

int main() {
	PhanSo ps1, ps2, tong, hieu, tich, thuong;
	ps1.nhapPhanSo();
	ps2.nhapPhanSo();
	tong = ps1 + ps2;
	cout << "Tong hai phan so la: ";
	tong.inPhanSo();
	hieu = ps1 - ps2;
	cout << "Hieu hai phan so la: ";
	hieu.inPhanSo();
	tich = ps1 * ps2;
	cout << "Tich hai phan so la: ";
	tich.inPhanSo();
	thuong = ps1 / ps2;
	cout << "Thuong hai phan so la: ";
	thuong.inPhanSo();
	if (ps1 == ps2)
	cout << "Hai phan so bang nhau." << endl;
	else
	cout << "Hai phan so khac nhau." << endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class soPhuc {
    private:
        float thuc, ao;
    public:
        soPhuc(): thuc(0), ao(0) {};
        soPhuc(float r, float i): thuc(r), ao(i) {};
        void Nhap() {
            cout << "Nhap phan thuc: ";
            cin >> thuc;
            cout << "Nhap phan ao: ";
            cin >> ao;
        }
        void In() {
            if(ao >= 0)
                cout << thuc << "+" << ao << "i" << endl;
            else
                cout << thuc << ao << "i" << endl;   
        }
        soPhuc operator +(soPhuc sp) {
            soPhuc tong;
            tong.thuc = thuc + sp.thuc;
            tong.ao = ao + sp.ao;
            return tong;
        }
        soPhuc operator -(soPhuc sp) {
            soPhuc hieu;
            hieu.thuc = thuc - sp.thuc;
            hieu.ao = ao - sp.ao;
            return hieu;
        }
        soPhuc operator *(soPhuc sp) {
            soPhuc tich;
            tich.thuc = thuc * sp.thuc - ao * sp.ao;
            tich.ao = thuc * sp.ao + ao * sp.thuc;
            return tich;
        }
        friend ostream& operator << (ostream& out, soPhuc& sp) {
            if(sp.ao >= 0)
                out << sp.thuc << "+" << sp.ao << "i" << endl;
            else
                out << sp.thuc << sp.ao << "i" << endl;  
            return out;     
        }
        friend istream& operator >> (istream& in, soPhuc& sp) {
            cout << "Nhap phan thuc: ";
            in >> sp.thuc;

            cout << "Nhap phan ao: ";
            in >> sp.ao;

            return in;
        }
};

int main(){
    soPhuc a, b, c; 
    cin >> a; 
    cout << "So phuc thu 1 la: " <<a; 
    cin >> b; 
    cout << "So phuc thu 2 la: " <<b; 
    c = a + b; 
    cout << "Tong hai so phuc la: " << c;
    c = a - b; 
    cout << "Hieu hai so phuc la: " << c;
    c = a * b; 
    cout << "Tich hai so phuc la: " << c;
    return 0;
}

# data[].attributes.attachment_link.readable_text
// Bai 1: Xay dung lop phan so 
#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
	
		int ucln(int a, int b) {
			if (b == 0) return a;
			return ucln(b, a%b);
		}
		
		void toiGianPhanSo() {
			int uc = ucln(ts, ms);
			ts /= uc;
			ms /= uc;
		}
	
		friend PhanSo operator+(const PhanSo& a, const PhanSo& b) {  // khai bao ham ban xai phep cong 
	        PhanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator-(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep tru
	        PhanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend PhanSo operator*(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep nhan 
	        PhanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator/(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep chia 
	        PhanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend bool operator==(const PhanSo& a, const PhanSo& b) {  // kiem tra so sanh 2 phan so 
	        return a.ts * b.ms == a.ms * b.ts;
	    }

};

int main() {
	PhanSo ps1, ps2, tong, hieu, tich, thuong;
	ps1.nhapPhanSo();
	ps2.nhapPhanSo();
	tong = ps1 + ps2;
	cout << "Tong hai phan so la: ";
	tong.inPhanSo();
	hieu = ps1 - ps2;
	cout << "Hieu hai phan so la: ";
	hieu.inPhanSo();
	tich = ps1 * ps2;
	cout << "Tich hai phan so la: ";
	tich.inPhanSo();
	thuong = ps1 / ps2;
	cout << "Thuong hai phan so la: ";
	thuong.inPhanSo();
	if (ps1 == ps2)
	cout << "Hai phan so bang nhau." << endl;
	else
	cout << "Hai phan so khac nhau." << endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;

class PhanSo {
private:
int ts, ms;
public:
void nhapPhanSo() {
cout << "Nhap tu so: ";
cin >> ts;
cout << "Nhap mau so: ";
cin >> ms;
}

void inPhanSo() {
cout << ts << "/" << ms << endl;
}

int ucln(int a, int b) {
if (b == 0) return a;
return ucln(b, a%b);
}

void toiGianPhanSo() {
int uc = ucln(ts, ms);
ts /= uc;
ms /= uc;
}

PhanSo operator+(PhanSo &ps) {
PhanSo tong;
tong.ts = ts * ps.ms + ps.ts * ms;
tong.ms = ms * ps.ms;
tong.toiGianPhanSo();
return tong;
}

PhanSo operator-(PhanSo &ps) {
PhanSo hieu;
hieu.ts= ts * ps.ms - ps.ts * ms;
hieu.ms = ms * ps.ms;
hieu.toiGianPhanSo();
return hieu;
}

PhanSo operator*(PhanSo &ps) {
PhanSo tich;
tich.ts = ts * ps.ts;
tich.ms = ms * ps.ms;
tich.toiGianPhanSo();
return tich;
}

PhanSo operator/(PhanSo &ps) {
PhanSo thuong;
thuong.ts = ts * ps.ms;
thuong.ms = ms * ps.ts;
thuong.toiGianPhanSo();
return thuong;
}

bool operator==(PhanSo &ps) {
return (ts == ps.ts && ms == ps.ms);
}

};

int main() {
PhanSo ps1, ps2, tong, hieu, tich, thuong;
ps1.nhapPhanSo();
ps2.nhapPhanSo();

// Tong
tong = ps1 + ps2;
cout << "Tong hai phan so la: ";
tong.inPhanSo();

// Hieu
hieu = ps1 - ps2;
cout << "Hieu hai phan so la: ";
hieu.inPhanSo();

// Tich
tich = ps1 * ps2;
cout << "Tich hai phan so la: ";
tich.inPhanSo();

// Thuong
thuong = ps1 / ps2;
cout << "Thuong hai phan so la: ";
thuong.inPhanSo();

// So sanh bang nhau
if (ps1 == ps2)
cout << "Hai phan so bang nhau." << endl;
else
cout << "Hai phan so khac nhau." << endl;
return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
	
		int ucln(int a, int b) {
			if (b == 0) return a;
			return ucln(b, a%b);
		}
		
		void toiGianPhanSo() {
			int uc = ucln(ts, ms);
			ts /= uc;
			ms /= uc;
		}
	
		friend PhanSo operator+(const PhanSo& a, const PhanSo& b) {  // khai bao ham ban xai phep cong 
	        PhanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator-(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep tru
	        PhanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend PhanSo operator*(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep nhan 
	        PhanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator/(const PhanSo& a, const PhanSo& b) { // khai bao ham ban xai phep chia 
	        PhanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend bool operator==(const PhanSo& a, const PhanSo& b) {  // kiem tra so sanh 2 phan so 
	        return a.ts * b.ms == a.ms * b.ts;
	    }

};

int main() {
	PhanSo ps1, ps2, tong, hieu, tich, thuong;
	ps1.nhapPhanSo();
	ps2.nhapPhanSo();
	tong = ps1 + ps2;
	cout << "Tong hai phan so la: ";
	tong.inPhanSo();
	hieu = ps1 - ps2;
	cout << "Hieu hai phan so la: ";
	hieu.inPhanSo();
	tich = ps1 * ps2;
	cout << "Tich hai phan so la: ";
	tich.inPhanSo();
	thuong = ps1 / ps2;
	cout << "Thuong hai phan so la: ";
	thuong.inPhanSo();
	if (ps1 == ps2)
	cout << "Hai phan so bang nhau." << endl;
	else
	cout << "Hai phan so khac nhau." << endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
const float PI=3.1459;
using namespace std;
class HinhTron{
	private:
		float bankinh;
	
	public:
		
		HinhTron(){}
		HinhTron(float r){
			bankinh=r;
		}
		
		void Nhap(){
			cout<<"Nhap ban kinh r = "; cin>>bankinh;
		}
		
		float ChuVi(){
			float chuvi;
			//float PI=3.1459;
				chuvi=2*bankinh*PI;
			return chuvi;
		}
		float DienTich(){
			float dientich;
			//float PI=3.1459;
				dientich=PI*bankinh*bankinh;
			return dientich;
		}
		~HinhTron(){}
};
int main(){
	HinhTron ht;
	ht.Nhap();
	
	cout<<"- Chu vi Hinh Tron : " <<ht.ChuVi()<<endl;
	cout<<"- Dien tich Hinh Tron : "<<ht.DienTich()<<endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include <conio.h>
#include <string>
using namespace std;

class ThiSinh{
	private:
		string sbd;
		float diemToan,diemLy,diemHoa;
				
	public:
		void Nhap();
		void Xuat();
		float TinhTongDiem();
};

		
void ThiSinh::Nhap(){
	cout<<"Nhap SBD : "; cin>>sbd;
	cout<<"Nhap diem Toan :"; cin>>diemToan;
	cout<<"Nhap diem Ly :"; cin>>diemLy;
	cout<<"Nhap diem Hoa :"; cin>>diemHoa;
	}
			

float ThiSinh::TinhTongDiem(){
		return diemToan+diemLy+diemHoa;
	}
		
void ThiSinh::Xuat(){
		cout<<"\n";
		cout<<"SBD : "<<sbd<<endl;
		cout<<"Diem Toan:"<<diemToan<<" - "<<"Diem Ly:"<<diemLy<<" - "<<"Diem Hoa:"<<diemHoa<<endl;
		cout<<"Tong diem = "<<TinhTongDiem();
		cout<<"\n";
	}
	
class DanhSach{
	int n;
	ThiSinh DSThiSinh[50];
	public:
		void NhapDS();
		void XuatDS();
		void TongTren18();
		void SapXep();
};

void DanhSach::NhapDS(){
	cout<<"Nhap so luong SV: " ; cin>>n;
	for(int i=0;i<n;i++){
		DSThiSinh[i].Nhap();
	}
}

void DanhSach::XuatDS(){
	for(int i=0;i<n;i++){
		DSThiSinh[i].Xuat();
	}
}

void DanhSach::TongTren18(){
	for(int i=0;i<n;i++){
		if(DSThiSinh[i].TinhTongDiem()>18){
			DSThiSinh[i].Xuat();
		}
	}
}

void DanhSach::SapXep(){
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++)
		if(DSThiSinh[i].TinhTongDiem()>DSThiSinh[j].TinhTongDiem()){
			ThiSinh temp;
			temp=DSThiSinh[i];
			DSThiSinh[i]=DSThiSinh[j];
			DSThiSinh[j]=temp;
		}
	}	
}


int main(){
	DanhSach ds;
	ds.NhapDS();
	
	cout<<"\n1. Sap xep diem theo tang dan : ";
		ds.SapXep();
		ds.XuatDS();
	
	cout<<"\n2. Danh sach thi sinh tren 18 diem : ";
		ds.TongTren18();
	
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <math.h>
using namespace std;

class soPhuc{
		int thuc, ao;	
	public: 
		soPhuc(){}
		soPhuc(int pt, int pa){ thuc = pt; ao = pa;}
		void nhap(){
			cout << "Nhap phan thuc: "; 
			cin >> thuc;
	        cout << "Nhap phan ao: "; 
			cin >> ao;
		}
		
		void in() {
        	cout << thuc << " + " << ao << "i";
    	}

		friend soPhuc operator+(const soPhuc a,const soPhuc b) {
			soPhuc c;
			c.thuc = a.thuc + b.thuc;
			c.ao = a.ao + b.ao;
			return c;
		}
		
		friend soPhuc operator-(const soPhuc a,const soPhuc b) {
			soPhuc c;
			c.thuc = a.thuc - b.thuc;
			c.ao = a.ao - b.ao;
			return c;
		}
		
		friend soPhuc operator*(const soPhuc a,const soPhuc b) {
			soPhuc c;
			c.thuc = a.thuc*b.thuc - a.ao*b.ao;
			c.ao = b.thuc*a.ao + a.thuc*b.ao;	
			return c;
		}
		friend ostream& operator << (ostream &out, const soPhuc &sp) {
			out << sp.thuc << " + " << sp.ao << "i";
			return out; 
		}
		
		friend istream& operator >> (istream &is, soPhuc &sp) {
			cout << "Nhap phan thuc: ";
	        is >> sp.thuc;
	        cout << "Nhap phan ao: ";
	        is >> sp.ao;
	        return is;
		}
};


int main() {
	soPhuc sp1, sp2, TT;
	cout << "Nhap so phuc thu nhat: \n"; 
	cin >> sp1;
//	sp1.nhap();
	cout << "\nNhap so phuc thu hai: \n"; 
//	sp2.nhap();
	cin >> sp2;
	
	TT = operator +(sp1, sp2);
	cout << "\nTong hai so phuc la: " << TT;
//	TT.in();
	
	TT = operator -(sp1, sp2);
	cout << "\nHieu hai so phuc la: " << TT;
//	TT.in();
	
	TT = operator *(sp1, sp2);
	cout << "\nTich hai so phuc la: " << TT;
//	TT.in();	
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class phanSo{
		double ts, ms;
	public:
		void nhap(){
			do{
				cout << "\nNhap Tu so: ";	
				cin >> ts;
				cout << "Nhap Mau so: ";
				cin>> ms;
				if(ms == 0){
					cout << "\nYeu cau nhap lai!" << endl;
				}
			}
			while(ms == 0);		
		}
		
		void in(){
			cout << ts << "/" << ms;
		}
		
		int UCLN(int a, int b) {
			if (b == 0) return a;
			return UCLN(b, a % b);
		}
		
		bool CheckToiGian() {
			int uc = UCLN(ts, ms);
			ts /= uc;
			ms /= uc;
			if (uc == 1)
				return 0;
			return 1;
		}
		
		void RutGonPS() {
			int uc = UCLN(ts, ms);
			ts /= uc;
			ms /= uc;
		}
		
		friend phanSo operator +(const phanSo& a, const phanSo& b) {  
	        phanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.RutGonPS();
	        return c;
	    }
		
		friend phanSo operator -(const phanSo& a, const phanSo& b) { 
	        phanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.RutGonPS();
	        return c;
	    }
	
		friend phanSo operator *(const phanSo& a, const phanSo& b) { 
	        phanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.RutGonPS();
	        return c;
	    }
		
		friend phanSo operator /(const phanSo& a, const phanSo& b) { 
	        phanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.RutGonPS();
	        return c;
	    }
	
		friend bool operator ==(const phanSo& a, const phanSo& b) {  
	        return a.ts * b.ms == a.ms * b.ts;
	    }
	    
	    friend bool operator <(const phanSo& a, const phanSo& b) {  
	        return a.ts * b.ms < a.ms * b.ts;
	    }
	    
//	    friend bool operator >(const phanSo& a, const phanSo& b) {  
//	        return a.ts * b.ms > a.ms * b.ts;
//	    }
		
};

int main(){
	phanSo ps1, ps2, TT;
	
	cout << "Nhap phan so thu nhat: ";
	ps1.nhap();
	if (ps1.CheckToiGian() == 0)
	cout << "Phan so da toi gian" << endl;
	else cout << "Phan so chua toi gian" << endl;
	
	cout << "\nNhap phan so thu hai: ";
	ps2.nhap();	
	if (ps2.CheckToiGian() == 0)
	cout << "Phan so da toi gian" << endl;
	else cout << "Phan so chua toi gian" << endl;
	
	if(ps1 == ps2)
	cout << "\nHai phan so bang nhau" << endl;
	else if(ps1 < ps2)
	cout << "\nPhan so thu nhat nho hon phan so thu hai" << endl;
	else
	cout << "\nPhan so thu hai nho hon phan so thu nhat" << endl;
	
	cout << "\nDay phan so sau khi rut gon la: " << endl;
	cout << "Phan so thu nhat: ";
	ps1.RutGonPS();
	ps1.in();
	cout << "\nPhan so thu hai: ";
	ps2.RutGonPS();
	ps2.in();
	
	TT = operator +(ps1, ps2);
	cout << "\n\nTong hai phan so la: ";
	TT.in();
	
	TT = operator -(ps1, ps2);
	cout << "\nHieu hai phan so la: ";
	TT.in();
	
	TT = operator *(ps1, ps2);
	cout << "\nTich hai phan so la: ";
	TT.in();
	
	TT = operator /(ps1, ps2);
	cout << "\nThuong hai phan so la: ";
	TT.in();	
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
const double pi = 3.14;

class Hinhtron{
		double r;
	public: 	
		void nhap(){	
		do{
            cout << "Nhap ban kinh: ";
            cin >> r;
            if (r <= 0){
                cout <<"Ban kinh phai > 0. Vui long nhap lai! " << endl;
        	}
        	else {
			cout << "Chu vi hinh tron: " <<  chuvi(pi,r) << endl;
			cout << "Dien tich hinh tron: " << dientich(pi,r) <<endl; 
			} 
        } 
		while(r <= 0);
		}
		
		double chuvi(double pi, double r) {
		return (2 * pi * r);
		}

		double dientich(double pi, double r) {
		return (pi * r * r);
		}
		
};

int main () {
	Hinhtron tinhtoan;
	tinhtoan.nhap();
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <math.h>
using namespace std;

class TamGiac{
		double a, b, c;
	public:
		void nhap(){
			
		do{
            cout << "Nhap cac canh a, b, c lan luot: " << endl;
			cin >> a >> b >> c;
            if (a <= 0 || b <= 0 || c <= 0){
                cout <<"Canh cua tam giac phai > 0. Vui long nhap lai! " << endl;
        	}
        	else {
			cout << "Cac canh da hop le " << endl;
			} 
        } 
		while(a <= 0 || b <= 0 || c <= 0);
		}
		
		void KiemTraTamGiac(double a, double b, double c) {
		if( a < b + c && b < a + c && c < a + b ){
 			if( a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b)
 				cout << "Day la tam giac vuong";
 			else if(a == b && b == c)
 				cout << "Day la tam giac deu";
 			else if(a == b || a == c || b == c)
 				cout << "Day la tam giac can";
 			else if(a * a > b * b + c * c || b * b > a * a + c * c || c * c > a * a + b * b) 
 				cout << "Day la tam giac tu";
 			else
 				cout << "Day la tam giac nhon";
 		}
 		else
  			cout << "Ba canh a, b, c khong phai la ba canh cua mot tam giac"; 			
		}
	
		double Dientich(double a, double b, double c) {
			double p = (a + b + c) / 2;
			return sqrt(p * (p - a) * (p - b) * (p - c));
		}
		
		void in() {
			KiemTraTamGiac(a, b, c);
			cout << "\nDien tich tam giac: " << Dientich(a, b, c);	
		}
};

int main() {
	double a, b, c;
	TamGiac canh;
	canh.nhap();
	canh.in();
}


# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class phanSo{
		double ts, ms;
	public:
		phanSo(){}
		phanSo(int tu, int mau){ ts = tu; ms = mau; }
		void nhap(){
			do{
				cout << "\nNhap Tu so: ";	
				cin >> ts;
				cout << "Nhap Mau so: ";
				cin>> ms;
				if(ms == 0){
					cout << "\nYeu cau nhap lai!" << endl;
				}
			}
			while(ms == 0);		
		}
		
		void in(){
			cout << ts << "/" << ms;
		}
		
		int UCLN(int a, int b) {
			if (b == 0) return a;
			return UCLN(b, a % b);
		}
		
		bool CheckToiGian() {
			int uc = UCLN(ts, ms);
			ts /= uc;
			ms /= uc;
			if (uc == 1)
				return 0;
			return 1;
		}
		
		void RutGonPS() {
			int uc = UCLN(ts, ms);
			ts /= uc;
			ms /= uc;
		}
		
		float Tong(phanSo x1, phanSo x2){
			int tu, mau;
			tu = x1.ts * x2.ms + x1.ms * x2.ts;
			mau = x1.ms * x2.ms;
			return (float) tu/mau;
		}
		
		float Hieu(phanSo x1, phanSo x2){
			int tu, mau;
			tu = x1.ts * x2.ms - x1.ms * x2.ts;
			mau = x1.ms * x2.ms;
			return (float) tu/mau;
		}
		
		float Tich(phanSo x1, phanSo x2){
			int tu, mau;
			tu = x1.ts * x2.ts;
			mau = x1.ms * x2.ms;
			return (float) tu/mau;
		}
		
		float Thuong(phanSo x1, phanSo x2){
			int tu, mau;
			tu = x1.ts * x2.ms;
			mau = x1.ms * x2.ts;
			return (float) tu/mau;
		}	
		
		friend bool operator ==(const phanSo& a, const phanSo& b) {  
	        return a.ts * b.ms == a.ms * b.ts;
	    }
	    
	    friend bool operator <(const phanSo& a, const phanSo& b) {  
	        return a.ts * b.ms < a.ms * b.ts;
	    }
	    
//	    friend bool operator >(const phanSo& a, const phanSo& b) {  
//	        return a.ts * b.ms > a.ms * b.ts;
//	    }
		

};

int main(){
	phanSo ps1, ps2, d;
	
	cout << "Nhap phan so thu nhat: ";
	ps1.nhap();
	if (ps1.CheckToiGian() == 0)
	cout << "Phan so da toi gian" << endl;
	else cout << "Phan so chua toi gian" << endl;
	
	cout << "\nNhap phan so thu hai: ";
	ps2.nhap();	
	if (ps2.CheckToiGian() == 0)
	cout << "Phan so da toi gian" << endl;
	else cout << "Phan so chua toi gian" << endl;
	
	if(ps1 == ps2)
	cout << "\nHai phan so bang nhau" << endl;
	else if(ps1 < ps2)
	cout << "\nPhan so thu nhat nho hon phan so thu hai" << endl;
	else
	cout << "\nPhan so thu hai nho hon phan so thu nhat" << endl;
	
	cout <<"\nTong 2 phan so la: " << d.Tong(ps1, ps2);
	cout <<"\nHieu 2 phan so la: " << d.Hieu(ps1, ps2);
	cout <<"\nTich 2 phan so la: " << d.Tich(ps1, ps2);
	cout <<"\nThuong 2 phan so la: " << d.Thuong(ps1, ps2);
	
	cout << "\n\nDay phan so sau khi rut gon la: " << endl;
	cout << "Phan so thu nhat: ";
	ps1.RutGonPS();
	ps1.in();
	cout << "\nPhan so thu hai: ";
	ps2.RutGonPS();
	ps2.in();
	
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class soPhuc{
		int pt, pa;	
	public:
		soPhuc(){}
		soPhuc(int thuc, int ao){ pt = thuc; pa = ao;}
		
		void nhap(){
			cout << "Nhap phan thuc: "; 
			cin >> pt;
	        cout << "Nhap phan ao: "; 
			cin >> pa;
		}
		
		void in(){
			cout<< pt << "+" << pa << "i" <<endl;
		}
		
		soPhuc tong(soPhuc p);
		soPhuc hieu(soPhuc p);
		soPhuc tich(soPhuc p);
};

soPhuc soPhuc::tong(soPhuc p){
	double thuc = pt + p.pt;
	double ao = pa + p.pa;
	return soPhuc(thuc, ao);
}
soPhuc soPhuc::hieu(soPhuc p){
	double thuc = pt - p.pt;
	double ao = pa - p.pa;
	return soPhuc(thuc, ao);
}
soPhuc soPhuc::tich(soPhuc p){
	double thuc = (pt * p.pt) - (pa * p.pa);
	double ao = (pa * p.pt) + (pt * p.pa);
	return soPhuc(thuc, ao);
}

int main()
{	
	soPhuc a;
	cout << "Nhap so phuc thu nhat: \n"; 
	a.nhap();
	soPhuc b;
	cout << "\nNhap so phuc thu hai: \n"; 
	b.nhap();
	
	cout<<"\nTong 2 so phuc vua nhap: ";
	(a.tong(b)).in();
	//(b.tong(a)).in();
	cout<<"Hieu 2 so phuc vua nhap: ";
	(a.hieu(b)).in();
	cout<<"Tich 2 so phuc vua nhap: ";
	(a.tich(b)).in();
	return 0;
}
    

////Cach khac: khong su dung ham tinh toan
//#include <iostream>
//using namespace std;
//
//class soPhuc{
//		int pt, pa;	
//	public:
//		soPhuc(){}
//		soPhuc(int thuc, int ao){ p_t = thuc; p_a = ao;}
//		
//		void nhap(){
//			cout << "Nhap phan thuc: "; 
//			cin >> pt;
//	        cout << "Nhap phan ao: "; 
//			cin >> pa;
//		}
//		
//		void tonghieutich(soPhuc a, soPhuc b){
//			cout << "\nTong 2 so phuc vua nhap: " << (a.pt + b.pt) << "+" << (a.pa + b.pa) << "*j" << endl;	
//			cout << "\nHieu 2 so phuc vua nhap: " << (a.pt - b.pt) << "-" << (a.pa - b.pa) << "*j" << endl;
//			cout << "\nTich 2 so phuc vua nhap: " << (a.pt*b.pt - a.pa*b.pa) << "+" << (b.pt*a.pa + a.pt*b.pa) << "*j" << endl;	
//		}			
//};
//
//int main() {
//	soPhuc a;
//	cout << "Nhap so phuc thu nhat: \n"; 
//	a.nhap();
//	soPhuc b;
//	cout << "\nNhap so phuc thu hai: \n"; 
//	b.nhap();
//	soPhuc c;
//	c.tonghieutich(a, b);
//}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class phanSo
{
public:
  int ts, ms;

public:
  phanSo()
  {
    ts = 0;
    ms = 0;
  }
  phanSo(int ts, int ms) : ts(ts), ms(ms) {}
  void nhapPS()
  {
    cout << "nhap ts : ";
    cin >> ts;
    cout << "nhap ms : ";
    cin >> ms;
  }
  void inPS() const
  {
    cout << ts << "/" << ms << endl;
  }
  int USLN()
  {
    int a = this->ts, b = this->ms;
    int tmp;
    while (b != 0)
    {
      tmp = a % b;
      a = b;
      b = tmp;
    }
    return a;
  }
  string kiemTraToiGian()
  {
    int a = USLN();
    if (a == 1)
      return "phan so tren da toi gian";
    else
      return "phan so tren chua toi gian";
  }
  phanSo toiGian()
  {
    int a = USLN();
    return phanSo(ts / a, ms / a);
  }
  friend const phanSo operator+(phanSo &ps1, phanSo &ps2);
  friend const phanSo operator-(phanSo &ps1, phanSo &ps2);
  friend const phanSo operator*(const phanSo &ps1, const phanSo &ps2);
  friend const phanSo operator/(const phanSo &ps1, const phanSo &ps2);
  friend const phanSo operator<<(const phanSo &ps1, const phanSo &ps2);
  friend void operator==(phanSo &ps1, phanSo &ps2);
  friend ostream& operator<<(ostream &out, const phanSo &ps);
};

const phanSo operator+(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms + ps2.ts * ps1.ms;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator-(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms - ps2.ts * ps1.ms;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator*(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ts;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator/(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms;
  int ms = ps1.ms * ps2.ts;
  return phanSo(ts, ms);
}

void operator==(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms - ps2.ts * ps1.ms;
  if (ts < 0)
  {
    cout << "phan so " << ps1 << " nho hon phan so " << ps2;
  }
  else if (ts == 0)
  {
    cout << "phan so " << ps1 << " bang phan so " << ps2;
  }
  else
  {
    cout << "phan so " << ps1 << " lon hon phan so " << ps2;
  }
}

ostream &operator<<(ostream &out, const phanSo &ps)
{
  out << ps.ts << "/" << ps.ms;
  return out;
}
main()
{
  phanSo ps1(1, 2), ps2(2, 3), ps3;
  ps3 = ps1 + ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 - ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 * ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 / ps2;
  ps3.toiGian().inPS();
  ps1 == ps2;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class soPhuc {
  int thuc, ao;
  public:
  soPhuc(){thuc=0; ao=0;}
  soPhuc(int t, int a) {
    this->thuc = t;
    this->ao = a;
  } 

  void nhapSoPhuc() {
    cout << "nhap phan thuc : ";
    cin >> thuc;
    cout << "nhap phan ao : ";
    cin >> ao;
  }

void inSoPhuc() {
        if (ao >= 0)
            cout << thuc << " + " << ao << "j" << endl;
        else
            cout << thuc << " - " << -ao << "j" << endl;
    }

  soPhuc operator+(soPhuc &sp) {
    return soPhuc(thuc + sp.thuc, ao + sp.ao);
  }

  soPhuc operator-(soPhuc &sp) {
    return soPhuc(thuc - sp.thuc, ao - sp.ao);
  }

  soPhuc operator*(soPhuc &sp) {
    return soPhuc(thuc * sp.thuc - ao * sp.ao, thuc * sp.ao + ao * sp.thuc);
  }

  friend ostream& operator<<(ostream&, const soPhuc &sp);
  friend istream& operator>>(istream&, soPhuc &sp);
 };

ostream& operator<<(ostream& out, const soPhuc& sp){
        if (sp.ao >= 0)
            out << sp.thuc << " + " << sp.ao << "j" << endl;
        else
            out << sp.thuc << " - " << -sp.ao << "j" << endl;
return out;
}
istream& operator>>(istream &in, soPhuc &sp){
  cout << "nhap phan thuc : ";
in>>sp.thuc;
  cout << "nhap phan ao : ";
in>>sp.ao;
return in;
}

 main() {
  soPhuc p1(1, 2), p2(2, 3), p3;
  cin >> p3;
  cout << "in so phuc : " << p3;
  p3 = p1 + p2;
  cout << p3;
  p3 = p1 - p2;
  cout << p3;
  p3 = p1 * p2;
  cout << p3;
 }

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>

using namespace std;

class numberList
{
private:
  vector<int> nums;

public:
  numberList() {}

  void addition(int num)
  {
    if (num % 2 != 0)
    {
      nums.push_back(num);
    }
  }

  int length() const
  {
    return nums.size();
  }

  void printNumbers() const
  {
    cout << "Danh sach cac so le la: ";
    for (int i = 0; i < nums.size(); i++)
    {
      cout << nums[i] << " ";
    }
    cout << endl;
  }

  void clear()
  {
    nums.clear();
  }

  numberList operator+(const numberList &NL) const
  {
    numberList newList;

    for (int i = 0; i < nums.size(); i++)
    {
      newList.addition(nums[i]);
    }

    for (int i = 0; i < NL.nums.size(); i++)
    {
      newList.addition(NL.nums[i]);
    }

    return newList;
  }

  numberList operator+(int X) const
  {
    numberList newList;
    for (int i = 0; i < nums.size(); i++)
    {
      newList.addition(nums[i]);
    }
    newList.addition(X);
    return newList;
  }

  void removeNumber(int X)
  {
    vector<int>::iterator it = nums.begin();
    while (it != nums.end())
    {
      if (*it == X)
      {
        it = nums.erase(it);
      }
      else
      {
        ++it;
      }
    }
  }

  int &operator[](int i)
  {
    return nums[i];
  }
};

int main()
{
  numberList list1, list2, list3;
  list1.addition(3);
  list1.addition(5);
  list1.addition(7);
  cout << "List 1:" << endl;
  list1.printNumbers();
  cout << "so luong so trong list la " << list1.length() << endl;
  

  list2.addition(9);
  list2.addition(11);
  cout << "List 2:" << endl;
  list2.printNumbers();

  list3 = list1 + list2;
  cout << "List 3 (List 1 + List 2):" << endl;
  list3.printNumbers();

  list3 = list3 + 13;
  cout << "List 3 + 13:" << endl;
  list3.printNumbers();

  list3.removeNumber(11);
  cout << "List 3 sau khi loai bo so 11:" << endl;
  list3.printNumbers();

  list3.clear();
  cout << "List 3 sau khi xoa:" << endl;
  list3.printNumbers();
  cout << "Gia tri tai index 1 = ";
  cout << list1[1];
  

  return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class PS{
		float ts,ms;
	public:
		PS(){};
		PS(float _ts,float _ms){
			this->ts = _ts;
			this->ms = _ms;
		};
		void nhap(){
			cout<<"nhap phan so";
			cin>>ts>>ms;
		}
		void in(){
			cout<<"phan so do la : "<<ts<<"/"<<ms;
		}
		int gcd(int ts, int ms) {
			if (ms == 0) {
				return ts;
			}
			return gcd(ms, ts % ms);
		}

		friend const PS operator -(const PS& ps1 , const PS& ps2);
		friend const PS operator +(const PS& ps1 , const PS& ps2);
		friend const PS operator /(const PS& ps1 , const PS& ps2);
		friend const PS operator *(const PS& ps1 , const PS& ps2);
		friend const PS operator ==(const PS& ps1 , const PS& ps2);	
};

const PS operator +(const PS& ps1 , const PS& ps2){
	int _ts = ps1.ts * ps2.ms + ps1.ms * ps2.ts;
	int _ms = ps1.ms * ps2.ms;
	return PS(_ts,_ms);
};
const PS operator -(const PS& ps1 , const PS& ps2){
	int _ts = ps1.ts * ps2.ms - ps1.ms * ps2.ts;
	int _ms = ps1.ms * ps2.ms;
	return PS(_ts,_ms);
};
const PS operator *(const PS& ps1 , const PS& ps2){
	int _ts = ps1.ts * ps2.ts;
	int _ms = ps1.ms * ps2.ms;
	return PS(_ts,_ms);
};
const PS operator /(const PS& ps1 , const PS& ps2){
	int _ts = ps1.ts * ps2.ms;
	int _ms = ps1.ms * ps2.ts;
	return PS(_ts,_ms);
};
const PS operator == (const PS& ps1 , const PS& ps2){
	int _ts = ps1.ts * ps2.ms;
	int _ts2 = ps2.ts * ps1.ms;
	if(_ts > _ts2){
		return PS(ps1.ts,ps1.ms);	
	}
	return PS(ps2.ts , ps2.ms);
}
int main(){
	PS p1(1,2) , p2(1,2), c;
	c = operator ==(p1,p2);
	cout<<"Phan so lon hon la : ";
	c.in();
}



# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
using namespace std;
class soPhuc{
	float thuc,ao;
	public:
		soPhuc(){};
		soPhuc(float _thuc,float _ao){
			this->thuc = _thuc;
			this->ao = _ao;
		};
		friend ostream& operator<<(ostream&, const soPhuc& sp);
		friend istream& operator>>(istream&, soPhuc& sp);
		friend const soPhuc operator +(const soPhuc &sp1, const soPhuc &sp2);
		friend const soPhuc operator -(const soPhuc &sp1,const soPhuc &sp2);
		friend const soPhuc operator *(const soPhuc &sp1,const soPhuc &sp2);
};
ostream& operator<<(ostream& out, const soPhuc& sp){
	out<<sp.thuc<<"+"<<sp.ao<<"*j";
	return out;
}
istream& operator>>(istream& in, soPhuc& sp){
	in>>sp.thuc>>sp.ao;
	return in;
}
const soPhuc operator+(const soPhuc &sp1,const soPhuc &sp2){
	int _thuc = sp1.thuc + sp2.thuc;
	int _ao = sp1.ao + sp2.ao;
	return soPhuc(_thuc,_ao);
}
const soPhuc operator-(const soPhuc &sp1,const soPhuc &sp2){
	int _thuc = sp1.thuc + sp2.thuc;
	int _ao = - (sp1.ao + sp2.ao);
	return soPhuc(_thuc,_ao);
}
const soPhuc operator*(const soPhuc &sp1 , const soPhuc &sp2){
	int _thuc = sp1.thuc*sp2.thuc - sp1.ao *sp2.ao;
	int _ao = sp1.ao*sp2.thuc + sp1.thuc *sp2.ao;
	return soPhuc(_thuc,_ao);
}
int main(){
	soPhuc s(2,3), s1(1,2),s2;
	s2 = operator+(s1,s2);
	cout<<"tong 2 so phuc la : "<<s2;
}


# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<vector>
using namespace std;

class numberList{
	public : vector<int> numList ;
	public :
		numberList(){};
		
		int addition(int x){
			if(x % 2 == 0 ) return 0 ;
			this->numList.push_back(x);
		}
		int length(){
			return this->numList.size(); 
		}
		void clear(){
			this -> numList.clear();
		}
		const numberList operator+(const numberList& nul);
		int &operator[](int i)
		{
		    return numList[i];
		}
		const numberList operator+(int x);
};
const numberList numberList::operator+(int x){
	numberList nl;
	nl.numList = this->numList;
	nl.numList.push_back(x);
	return nl;
}
const numberList numberList::operator+(const numberList& nul){
	numberList nl;
    nl.numList = this->numList;
    nl.numList.insert(nl.numList.end(), nul.numList.begin(), nul.numList.end());
    return nl;
} 

int main(){
	numberList nl,nl2,nl3,nl4 ; 
	nl.addition(1);
	nl.addition(5);
	nl.addition(3);
	nl2.addition(7);
	nl3 = nl+nl2;
	nl4 = nl3.operator+(9);
	cout<<"Do dai cua nl3 la : "<<nl3.length()<<endl;
	cout<<"Do dai cua nl4 sau khi them x la "<<nl4.length();
}





# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
	
		int kt(int a, int b) {
			if (b == 0) return a;
			return kt(b, a%b);
		}
		
		void toiGianPhanSo() {
			int tg = kt(ts, ms);
			ts /= tg;
			ms /= tg;
		}
		
		// khai bao ham ban xai phep cong
		friend PhanSo operator+(const PhanSo& a, const PhanSo& b) {   
	        PhanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		// khai bao ham ban xai phep tru
		friend PhanSo operator-(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		// khai bao ham ban xai phep nhan
		friend PhanSo operator*(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		// khai bao ham ban xai phep chia 
		friend PhanSo operator/(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		// kiem tra so sanh 2 phan so
		friend bool operator==(const PhanSo& a, const PhanSo& b) {   
	        return a.ts * b.ms == a.ms * b.ts;
	    }

};

int main() {
	PhanSo a, b, tong, hieu, tich, thuong;
	a.nhapPhanSo();
	b.nhapPhanSo();
	tong = a + b;
	cout << "Tong hai phan so la: ";
	tong.inPhanSo();
	hieu = a - b;
	cout << "Hieu hai phan so la: ";
	hieu.inPhanSo();
	tich = a * b;
	cout << "Tich hai phan so la: ";
	tich.inPhanSo();
	thuong = a / b;
	cout << "Thuong hai phan so la: ";
	thuong.inPhanSo();
	if (a == b)
	cout << "Hai phan so bang nhau." << endl;
	else
	cout << "Hai phan so khac nhau." << endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class soPhuc {
    private:
        float thuc, ao;
    public:
        soPhuc(): thuc(0), ao(0) {};
        soPhuc(float t, float a){
        	thuc=t;
        	ao=a;
		};
        void nhap() {
            cout << "Nhap phan thuc: ";
            cin >> thuc;
            cout << "Nhap phan ao: ";
            cin >> ao;
        }
        void in() {
            if(ao >= 0)
                cout << thuc << "+" << ao << "i" << endl;
            else
                cout << thuc << ao << "i" << endl;   
        }
        soPhuc operator +(soPhuc sp) {
            soPhuc tong;
            tong.thuc = thuc + sp.thuc;
            tong.ao = ao + sp.ao;
            return tong;
        }
        soPhuc operator -(soPhuc sp) {
            soPhuc hieu;
            hieu.thuc = thuc - sp.thuc;
            hieu.ao = ao - sp.ao;
            return hieu;
        }
        soPhuc operator *(soPhuc sp) {
            soPhuc tich;
            tich.thuc = thuc * sp.thuc - ao * sp.ao;
            tich.ao = thuc * sp.ao + ao * sp.thuc;
            return tich;
        }
        friend ostream& operator << (ostream& out, soPhuc& sp) {
            if(sp.ao >= 0)
                out << sp.thuc << "+" << sp.ao << "i" << endl;
            else
                out << sp.thuc << sp.ao << "i" << endl;  
            return out;     
        }
        friend istream& operator >> (istream& in, soPhuc& sp) {
            cout << "Nhap phan thuc: ";
            in >> sp.thuc;

            cout << "Nhap phan ao: ";
            in >> sp.ao;

            return in;
        }
};

int main(){
    soPhuc a, b, c; 
    cin >> a; 
    cout << "So phuc thu 1 la: " <<a; 
    cin >> b; 
    cout << "So phuc thu 2 la: " <<b; 
    c = a + b; 
    cout << "Tong hai so phuc la: " << c;
    c = a - b; 
    cout << "Hieu hai so phuc la: " << c;
    c = a * b; 
    cout << "Tich hai so phuc la: " << c;
    return 0;
}


# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class PS{
	int ts,ms;
	public:
		PS(){
			ts =0;
			ms=1;
		}
		PS(int t,int m){
			ts=t;
			ts=m;
		}
		void nhap();
    	void in();
    	PS tong(PS);
    	PS hieu(PS);
    	friend PS tich(PS, PS);
    	friend PS thuong(PS, PS);
    	int UCLN(int, int);
    	PS toigian();
		bool laToiGian();
//		friend PS tich(PS,PS);
//		friend PS thuong(PS,PS);

};
void PS::nhap(){
			do{
				cout<<"Nhap tu so: ";
				cin>>ts;
				cout<<"Nhap mau so: ";
				cin>>ms;
				if(ms==0){
					cout<<"Mau so ko dc = 0,moi` nhap lai!"<<endl;
				}
			}while(ms==0);
		}
		void PS::in(){
			cout<<ts<<"/"<<ms<<endl;
		}


		int PS::UCLN(int a,int b){
			if(a < 0) a = -a;
			
        	if(b < 0) b = -b;
        	
        	while(a != b) {
        		
            	if(a > b) a = a - b;
            	
            	else b = b - a;
        }
        return a;
    }
	 bool PS::laToiGian() {
        int ucln = UCLN(ts, ms);
        if (ucln == 1)
            return true;
        else
            return false;
    }
			
	PS PS::toigian(){
        PS tg;
        int ucln = this->UCLN(ts, ms);
        ts /= ucln;
        ms /= ucln;
        return tg;
    }
		PS PS::tong(PS b) {
        	PS c;
        	c.ts = ts*b.ms + ms*b.ts;
        	c.ms = ms*b.ms;
			return c.toigian();
		}
		PS PS::hieu(PS b){
		PS c;
		c.ts = ts*b.ms - b.ts*ms;
    	c.ms = ms*b.ms;
    	return c.toigian();
		}    
		
PS tich(PS a,PS b)	{
	PS c;
	c.ts = a.ts * b.ts;
    c.ms = a.ms * b.ms;
	return c.toigian();
}
PS thuong(PS a,PS b)	{
	PS c;
	c.ts = a.ts * b.ms;
    c.ms = a.ms * b.ts;
	return c.toigian();
}		
		
int main(){
	PS a,b,c;
	cout<<"Nhap phan so a: "<<endl;
	a.nhap();
	cout<<"Nhap phan so b:"<<endl;
	b.nhap();
	cout<<"Phan so a: ";
	a.in();
    if (a.laToiGian())
        cout << "Day la phan so toi gian."<<endl;
    else {
        cout << "Day khong phai la phan so toi gian."<<endl;
        a.toigian();
        cout << "Phan so sau khi toi gian la: ";
        a.in();
    }	
	cout<<"Phan so b: ";
	b.in();
    if (b.laToiGian())
        cout << "Day la phan so toi gian."<<endl;
    else {
        cout << "Day khong phai la phan so toi gian."<<endl;
        b.toigian();
        cout << "Phan so sau khi toi gian la: "<<endl;
        b.in();
    }	
	c=a.tong(b);
	cout<<"Tong 2 phan so la: ";
	c.in();
	cout<<"Hieu 2 phan so la: ";
	c = a.hieu(b);
	c.in();
	cout << "Tich hai phan so: ";
    c = tich(a, b);
    c.in();
    cout << "Thuong hai phan so: ";
    c = thuong(a, b);
    c.in();
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;
class soPhuc{
    private:
        float thuc, ao;
    public:
        soPhuc(){
            thuc = 0;
            ao = 0;
        }
        soPhuc(float thuc, float ao){
            this->thuc = thuc;
            this->ao = ao;
        }
        void nhap(){
            cout<<"Nhap phan thuc: ";
            cin>>thuc;
            cout<<"Nhap phan ao: ";
            cin>>ao;
        }
        void in(){
            cout<<thuc<<" + "<<ao<<"*j"<<endl;
        }
        soPhuc tong(soPhuc sp){
            soPhuc kq;
            kq.thuc = thuc + sp.thuc;
            kq.ao = ao + sp.ao;
            return kq;
        }
        soPhuc hieu(soPhuc sp){
            soPhuc kq;
            kq.thuc = thuc - sp.thuc;
            kq.ao = ao - sp.ao;
            return kq;
        }
        soPhuc tich(soPhuc sp){
            soPhuc kq;
            kq.thuc = thuc*sp.thuc - ao*sp.ao;
            kq.ao = ao*sp.thuc + thuc*sp.ao;
            return kq;
        }
};
int main(){
    soPhuc sp1, sp2;
    cout<<"Nhap so phuc thu nhat: "<<endl;
    sp1.nhap();
    cout<<"Nhap so phuc thu hai: "<<endl;
    sp2.nhap();
    cout<<"So phuc thu nhat: ";
    sp1.in();
    cout<<"So phuc thu hai: ";
    sp2.in();
    cout<<"Tong hai so phuc: ";
    soPhuc kq = sp1.tong(sp2);
    kq.in();
    cout<<"Hieu hai so phuc: ";
    kq = sp1.hieu(sp2);
    kq.in();
    cout<<"Tich hai so phuc: ";
    kq = sp1.tich(sp2);
    kq.in();
    return 0;
}


# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;

class PS{
	int ts,ms;
	public:
		PS(){
			ts =0;
			ms=1;
		}
		PS(int t,int m){
			ts=t;
			ms=m;
		}
		void nhap();
    	void in();
    	int UCLN(int, int);
    	PS toigian();
		bool laToiGian();
		PS operator+(const PS&);
    	PS operator-(const PS&);
    	PS operator*(const PS&);
    	PS operator/(const PS&);
		bool operator==(const PS&);

};
void PS::nhap(){
			do{
				cout<<"Nhap tu so: ";
				cin>>ts;
				cout<<"Nhap mau so: ";
				cin>>ms;
				if(ms==0){
					cout<<"Mau so ko dc = 0,moi` nhap lai!"<<endl;
				}
			}while(ms==0);
		}
		void PS::in(){
			cout<<ts<<"/"<<ms<<endl;
		}


		int PS::UCLN(int a,int b){
			if(a < 0) a = -a;
			
        	if(b < 0) b = -b;
        	
        	while(a != b) {
        		
            	if(a > b) a = a - b;
            	
            	else b = b - a;
        }
        return a;
    }
	 bool PS::laToiGian() {
        int ucln = UCLN(ts, ms);
        if (ucln == 1)
            return true;
        else
            return false;
    }
			
	PS PS::toigian(){
        PS tg;
        int ucln = UCLN(ts, ms);
        ts /= ucln;
        ms /= ucln;
        return *this;
    }
		PS PS::operator+(const PS& b) {
        	PS c;
        	c.ts = ts*b.ms + ms*b.ts;
        	c.ms = ms*b.ms;
			return c.toigian();
		}
		PS PS::operator-(const PS& b){
		PS c;
		c.ts = ts*b.ms - b.ts*ms;
    	c.ms = ms*b.ms;
    	return c.toigian();
		}    
		
PS PS::operator*(const PS& b) {
    PS c;
    c.ts = ts * b.ts;
    c.ms = ms * b.ms;
    return c.toigian();
}
PS PS::operator/(const PS& b) {
    PS c;
    c.ts = ts * b.ms;
    c.ms = ms * b.ts;
    return c.toigian();
}
bool PS::operator==(const PS& b) {
    return (ts * b.ms == b.ts * ms);
}		
		
int main(){
	PS a,b,c;
	cout<<"Nhap phan so a: "<<endl;
	a.nhap();
	cout<<"Nhap phan so b:"<<endl;
	b.nhap();
	cout<<"Phan so a: ";
	a.in();
    if (a.laToiGian())
        cout << "Day la phan so toi gian."<<endl;
    else {
        cout << "Day khong phai la phan so toi gian."<<endl;
        a.toigian();
        cout << "Phan so sau khi toi gian la: ";
        a.in();
    }	
	cout<<"Phan so b: ";
	b.in();
    if (b.laToiGian())
        cout << "Day la phan so toi gian."<<endl;
    else {
        cout << "Day khong phai la phan so toi gian."<<endl;
        b.toigian();
        cout << "Phan so sau khi toi gian la: "<<endl;
        b.in();
    }	
	c=a+b;
	cout<<"Tong 2 phan so la: ";
	c.in();
	cout<<"Hieu 2 phan so la: ";
	c = a-b;
	c.in();
	cout << "Tich hai phan so: ";
    c = a*b;
    c.in();
    cout << "Thuong hai phan so: ";
    c = a/b;
    c.in();
    if (a==b)
	cout<<"2 phan so bang nhau"<<endl;
	else
	cout<<"2 phan so khac nhau"<<endl;
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class soPhuc {
private:
    double thuc, ao;
public:
    soPhuc() {
        thuc = 0;
        ao = 0;
    }
    soPhuc(double r, double i) {
        thuc = r;
        ao = i;
    }
    void nhapSoPhuc() {
        cout << "Nhap phan thuc: ";
        cin >> thuc;
        cout << "Nhap phan ao: ";
        cin >> ao;
    }
    void inSoPhuc() {
        cout << thuc << " + " << ao << "i" << endl;
    }
    friend soPhuc operator+(const soPhuc& sp1, const soPhuc& sp2);
    friend soPhuc operator-(const soPhuc& sp1, const soPhuc& sp2);
    friend soPhuc operator*(const soPhuc& sp1, const soPhuc& sp2);
    friend istream& operator>>(istream& is, soPhuc& sp);
    friend ostream& operator<<(ostream& os, const soPhuc& sp);
};

soPhuc operator+(const soPhuc& sp1, const soPhuc& sp2) {
    return soPhuc(sp1.thuc + sp2.thuc, sp1.ao + sp2.ao);
}

soPhuc operator-(const soPhuc& sp1, const soPhuc& sp2) {
    return soPhuc(sp1.thuc - sp2.thuc, sp1.ao - sp2.ao);
}

soPhuc operator*(const soPhuc& sp1, const soPhuc& sp2) {
    return soPhuc(sp1.thuc * sp2.thuc - sp1.ao * sp2.ao, sp1.ao * sp2.thuc + sp1.thuc * sp2.ao);
}

istream& operator>>(istream& is, soPhuc& sp) {
    cout << "Nhap phan thuc: ";
    is >> sp.thuc;
    cout << "Nhap phan ao: ";
    is >> sp.ao;
    return is;
}

ostream& operator<<(ostream& os, const soPhuc& sp) {
    os << sp.thuc << " + " << sp.ao << "i" << endl;
    return os;
}

int main() {
    soPhuc sp1, sp2, sp3;
    cout << "Nhap so phuc 1: " << endl;
    cin >> sp1;
    cout << "Nhap so phuc 2: " << endl;
    cin >> sp2;
    sp3 = sp1 + sp2;
    cout << "Tong hai so phuc la: " << sp3;
    sp3 = sp1 - sp2;
    cout << "Hieu hai so phuc la: " << sp3;
    sp3 = sp1 * sp2;
    cout << "Tich hai so phuc la: " << sp3;
    return 0;
}


# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
	
		int ucln(int a, int b) {
			if (b == 0) return a;
			return ucln(b, a%b);
		}
		
		void toiGianPhanSo() {
			int uc = ucln(ts, ms);
			ts /= uc;
			ms /= uc;
		}
	
		friend PhanSo operator+(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ms + b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator-(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ms - b.ts * a.ms;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend PhanSo operator*(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ts;
	        c.ms = a.ms * b.ms;
	        c.toiGianPhanSo();
	        return c;
	    }
		
		friend PhanSo operator/(const PhanSo& a, const PhanSo& b) { 
	        PhanSo c;
	        c.ts = a.ts * b.ms;
	        c.ms = a.ms * b.ts;
	        c.toiGianPhanSo();
	        return c;
	    }
	
		friend bool operator==(const PhanSo& a, const PhanSo& b) { 
	        return a.ts * b.ms == a.ms * b.ts;
	    }

};

int main() {
	PhanSo ps1, ps2, tong, hieu, tich, thuong;
	ps1.nhapPhanSo();
	ps2.nhapPhanSo();
	tong = ps1 + ps2;
	cout << "Tong hai phan so la: ";
	tong.inPhanSo();
	hieu = ps1 - ps2;
	cout << "Hieu hai phan so la: ";
	hieu.inPhanSo();
	tich = ps1 * ps2;
	cout << "Tich hai phan so la: ";
	tich.inPhanSo();
	thuong = ps1 / ps2;
	cout << "Thuong hai phan so la: ";
	thuong.inPhanSo();
	if (ps1 == ps2)
	cout << "Hai phan so bang nhau." << endl;
	else
	cout << "Hai phan so khac nhau." << endl;
	return 0;
}
    

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;
class phanso
{
private:
    int ts,ms;
public:
    phanso (){}
    phanso(int t,int m):ts(t),ms(m){};
    void in(){cout<<ts<<"/"<<ms;}
//----------
    int UCLN(int ts, int ms) {
    while(ts * ms != 0) {
        if (ts > ms) {
            ts %= ms;
        }else{
            ms %= ts;
        }
    }
    return ts + ms;}
    phanso toiGian(){
        int t= ts/UCLN(ts,ms);
        int m= ms/UCLN(ts,ms);
        return phanso(t,m);
    }
//---------
    void so_toigian(){
        if (UCLN(ts,ms)==1)
        {
            cout<<"Phan so da toi gian ";
        } else {
            cout<<" phan so nay chua toi gian "<<endl;
            cout<<"so da toi gian la :";
        }
        
    }

    friend phanso operator+(phanso& ps,phanso& ps1){
        phanso q;
        q.ts=ps.ts*ps1.ms + ps.ms*ps1.ts;
        q.ms=ps.ms*ps1.ms;
        return q;
    }

    friend phanso operator-(phanso& ps,phanso& ps1){
        phanso q;
        q.ts=ps.ts*ps1.ms - ps.ms*ps1.ts;
        q.ms=ps.ms*ps1.ms;
        return q;
    }
    friend phanso operator*(phanso& ps,phanso& ps1){
        phanso q;
        q.ts= ps.ts*ps1.ts;
        q.ms= ps.ms*ps1.ms;
        return q;
    }
    friend phanso operator/(phanso& ps,phanso& ps1){
        phanso q;
        q.ts= ps.ts*ps1.ms;
        q.ms= ps.ms*ps1.ts;
        return q;
    }
    friend phanso operator&&(phanso& ps,phanso& ps1){
        if (ps.ms == ps1.ms)
        {
            if (ps.ts>ps1.ts)
            {
                cout<<"phan so 1 > phan so 2"<<endl;
            }else cout<<"phan so 1 < phan so 2"<<endl;
        }
        if (ps.ts== ps1.ts)
        {
            if (ps.ms>ps1.ms)
            {
                cout<<"phan so 1 < phan so 2"<<endl;
            }else cout<<"phan sp 1 > phan so 2"<<endl; 
        }
        
    }

    friend istream& operator>>(istream& in, phanso& a){
        in>>a.ts>>a.ms;
    }
};

int main(){
    phanso a,b,kq, k1;
    cout<<"phan so 1 :";cin>>a;
        cout<<"phan so 2 :";cin>>b;
    cout<<"tong = ";kq =a+b;
    kq.in();
    kq.so_toigian();
    k1=kq.toiGian();
    k1.in();

    cout<<"\nhieu = ";kq =a-b;
    kq.in();
    kq.so_toigian();
    k1=kq.toiGian();
    k1.in();

    cout<<"\ntich = ";kq =a*b;
    kq.in();
    kq.so_toigian();
    k1=kq.toiGian();
    k1.in();

    cout<<"\nthuong = ";kq =a/b;
    kq.in();
    kq.so_toigian();
    k1=kq.toiGian();
    k1.in();
    return 0;
}
  // friend ostream& operator<<(ostream& out,phanso& a){
    //     out<<a.ts<<"/"<<a.ms;
    //     return out;
    // }

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;
 class sophuc
 {
 private:
    int ao,thuc;
 public:
    sophuc(){};
    sophuc(int t,int a):thuc(t),ao(a){};
    friend ostream& operator<<(ostream& out,sophuc &o){
        out<<o.thuc<<"+"<<o.ao<<"i"<<endl;
        return out;
    }
    friend istream& operator>>(istream& in,sophuc &i){
        cout<<"thuc: ";cin>>i.thuc;
        cout<<"\nao: ";cin>>i.ao;
        return in;
    }

    friend sophuc operator+(sophuc &sp,sophuc &sp1){
        sophuc s;
        s.thuc=sp1.thuc+sp.thuc;
        s.ao=sp.ao+sp1.ao;
        return s;
    }
    friend sophuc operator-(sophuc &sp,sophuc &sp1){
        sophuc s;
        s.thuc=sp.thuc-sp1.thuc;
        s.ao= sp.ao-sp1.ao;
        return s;
    }
    friend sophuc operator*(sophuc &sp,sophuc &sp1){
        sophuc s;
        s.thuc = sp.thuc * sp1.thuc - sp.ao * sp1.ao;
        s.ao = sp.thuc * sp1.ao + sp.ao * sp1.thuc;
        return s;
    }
 };
 int main(){
    sophuc a,b,kq;
    cout << "Nhap so phuc thu 1:\n"; cin >> a;
    cout << "Nhap so phuc thu 2:\n"; cin >> b;

    cout << "So phuc thu 1: " << a << endl;
    cout << "So phuc thu 2: " << b << endl;
    kq =a+b;
    cout << "Tong = : "<<kq;
    kq = a - b ;
    cout << "\n Hieu = " <<kq;
    kq = a*b;
    cout << "\n Tich = " <<kq;
    return 0;
 }

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

class phanSo
{
public:
  int ts, ms;

public:
  phanSo()
  {
    ts = 0;
    ms = 0;
  }
  phanSo(int ts, int ms) : ts(ts), ms(ms) {}
  void nhapPS()
  {
    cout << "nhap ts : ";
    cin >> ts;
    cout << "nhap ms : ";
    cin >> ms;
  }
  void inPS() const
  {
    cout << ts << "/" << ms << endl;
  }
  int USLN()
  {
    int a = this->ts, b = this->ms;
    int tmp;
    while (b != 0)
    {
      tmp = a % b;
      a = b;
      b = tmp;
    }
    return a;
  }
  string kiemTraToiGian()
  {
    int a = USLN();
    if (a == 1)
      return "phan so tren da toi gian";
    else
      return "phan so tren chua toi gian";
  }
  phanSo toiGian()
  {
    int a = USLN();
    return phanSo(ts / a, ms / a);
  }
  friend const phanSo operator+(phanSo &ps1, phanSo &ps2);
  friend const phanSo operator-(phanSo &ps1, phanSo &ps2);
  friend const phanSo operator*(const phanSo &ps1, const phanSo &ps2);
  friend const phanSo operator/(const phanSo &ps1, const phanSo &ps2);
  friend const phanSo operator<<(const phanSo &ps1, const phanSo &ps2);
  friend void operator==(phanSo &ps1, phanSo &ps2);
  friend ostream& operator<<(ostream &out, const phanSo &ps);
};

const phanSo operator+(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms + ps2.ts * ps1.ms;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator-(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms - ps2.ts * ps1.ms;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator*(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ts;
  int ms = ps1.ms * ps2.ms;
  return phanSo(ts, ms);
}

const phanSo operator/(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms;
  int ms = ps1.ms * ps2.ts;
  return phanSo(ts, ms);
}

void operator==(phanSo &ps1, phanSo &ps2)
{
  int ts = ps1.ts * ps2.ms - ps2.ts * ps1.ms;
  if (ts < 0)
  {
    cout << "phan so " << ps1 << " nho hon phan so " << ps2;
  }
  else if (ts == 0)
  {
    cout << "phan so " << ps1 << " bang phan so " << ps2;
  }
  else
  {
    cout << "phan so " << ps1 << " lon hon phan so " << ps2;
  }
}

ostream &operator<<(ostream &out, const phanSo &ps)
{
  out << ps.ts << "/" << ps.ms;
  return out;
}
main()
{
  phanSo ps1(1, 2), ps2(2, 3), ps3;
  ps3 = ps1 + ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 - ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 * ps2;
  ps3.toiGian().inPS();
  ps3 = ps1 / ps2;
  ps3.toiGian().inPS();
  ps1 == ps2;
}

# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;
class PhanSo {
	private:
		int ts, ms;
	public:
		void nhapPhanSo() {
			cout << "Nhap tu so: ";
			cin >> ts;
			cout << "Nhap mau so: ";
			cin >> ms;
		}
		void inPhanSo() {
			cout << ts << "/" << ms << endl;
		}
		int ucln(int a, int b) {
			if (b == 0) return a;
			return ucln(b, a%b);
		}

		void toiGianPhanSo() {
			int uc = ucln(ts, ms);
			ts /= uc;
			ms /= uc;
		}

PhanSo operator+(PhanSo &ps) {	
		PhanSo tong;
		tong.ts = ts * ps.ms + ps.ts * ms;
		tong.ms = ms * ps.ms;
		tong.toiGianPhanSo();
		return tong;
}

PhanSo operator-(PhanSo &ps) {
		PhanSo hieu;
		hieu.ts= ts * ps.ms - ps.ts * ms;
		hieu.ms = ms * ps.ms;
		hieu.toiGianPhanSo();
		return hieu;
}

PhanSo operator*(PhanSo &ps) {
		PhanSo tich;
		tich.ts = ts * ps.ts;
		tich.ms = ms * ps.ms;
		tich.toiGianPhanSo();
		return tich;
}

PhanSo operator/(PhanSo &ps) {
		PhanSo thuong;
		thuong.ts = ts * ps.ms;
		thuong.ms = ms * ps.ts;
		thuong.toiGianPhanSo();
		return thuong;
}
bool operator==(PhanSo &ps) {
return (ts == ps.ts && ms == ps.ms);
}

};

int main() {
PhanSo ps1, ps2, tong, hieu, tich, thuong;
ps1.nhapPhanSo();
ps2.nhapPhanSo();

// Tong
tong = ps1 + ps2;
cout << "Tong hai phan so la: ";
tong.inPhanSo();

// Hieu
hieu = ps1 - ps2;
cout << "Hieu hai phan so la: ";
hieu.inPhanSo();

// Tich
tich = ps1 * ps2;
cout << "Tich hai phan so la: ";
tich.inPhanSo();

// Thuong
thuong = ps1 / ps2;
cout << "Thuong hai phan so la: ";
thuong.inPhanSo();

// So sanh bang nhau
if (ps1 == ps2)
cout << "Hai phan so bang nhau." << endl;
else
cout << "Hai phan so khac nhau." << endl;
return 0;
}

# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;
class PhanSo {
private:
int ts, ms;
public:
void nhapPhanSo() {
cout << "Nhap tu so: ";
cin >> ts;
cout << "Nhap mau so: ";
cin >> ms;
}
void inPhanSo() {
cout << ts << "/" << ms << endl;
}
int ucln(int a, int b) {
if (b == 0) return a;
return ucln(b, a%b);
}

void toiGianPhanSo() {
int uc = ucln(ts, ms);
ts /= uc;
ms /= uc;
}

PhanSo operator+(PhanSo &ps) {	
PhanSo tong;
tong.ts = ts * ps.ms + ps.ts * ms;
tong.ms = ms * ps.ms;
tong.toiGianPhanSo();
return tong;
}

PhanSo operator-(PhanSo &ps) {
PhanSo hieu;
hieu.ts= ts * ps.ms - ps.ts * ms;
hieu.ms = ms * ps.ms;
hieu.toiGianPhanSo();
return hieu;
}

PhanSo operator*(PhanSo &ps) {
PhanSo tich;
tich.ts = ts * ps.ts;
tich.ms = ms * ps.ms;
tich.toiGianPhanSo();
return tich;
}

PhanSo operator/(PhanSo &ps) {
PhanSo thuong;
thuong.ts = ts * ps.ms;
thuong.ms = ms * ps.ts;
thuong.toiGianPhanSo();
return thuong;
}
bool operator==(PhanSo &ps) {
return (ts == ps.ts && ms == ps.ms);
}

};

int main() {
PhanSo ps1, ps2, tong, hieu, tich, thuong;
ps1.nhapPhanSo();
ps2.nhapPhanSo();

// Tong
tong = ps1 + ps2;
cout << "Tong hai phan so la: ";
tong.inPhanSo();

// Hieu
hieu = ps1 - ps2;
cout << "Hieu hai phan so la: ";
hieu.inPhanSo();

// Tich
tich = ps1 * ps2;
cout << "Tich hai phan so la: ";
tich.inPhanSo();

// Thuong
thuong = ps1 / ps2;
cout << "Thuong hai phan so la: ";
thuong.inPhanSo();

// So sanh bang nhau
if (ps1 == ps2)
cout << "Hai phan so bang nhau." << endl;
else
cout << "Hai phan so khac nhau." << endl;
return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
using namespace std;
class soPhuc{
	private:
		float soThuc,soAo;
	public:
		soPhuc(){}
		
		void Nhap(){
			cout<<"Nhap so Thuc: "; cin>>soThuc;
			cout<<"Nhap so Ao: "; cin>>soAo;
		}
		
		void Xuat(){
			cout<<soThuc<<"+"<<soAo<<"i";
		}
		
		friend soPhuc operator + (soPhuc &sp1, soPhuc &sp2){
			soPhuc s;
			s.soThuc=sp1.soThuc+sp2.soThuc;
			s.soAo=sp1.soAo+sp2.soAo;
			return s;
		}
		friend soPhuc operator - (soPhuc &sp1, soPhuc &sp2){
			soPhuc s;
			s.soThuc=sp1.soThuc-sp2.soThuc;
			s.soAo=sp1.soAo-sp2.soAo;
			return s;
		}
		friend soPhuc operator * (soPhuc &sp1, soPhuc &sp2){
			soPhuc s;
			s.soThuc=sp1.soThuc+sp2.soThuc - sp1.soAo*sp2.soAo;
			s.soAo=sp1.soThuc*sp2.soAo + sp1.soAo*sp2.soThuc;
			return s;
		}
};


int main(){
	soPhuc sp1;
	soPhuc sp2;
	soPhuc cong,tru,nhan;
	
	sp1.Nhap();
	sp2.Nhap();
	
	cong=sp1+sp2;
	tru=sp1-sp2;
	nhan=sp1*sp2;

	cout<<"\nCong 2 so phuc : ";
	cong.Xuat();
	cout<<"\nTru 2 so phuc : ";
	tru.Xuat();
	cout<<"\nNhan 2 so phuc : ";
	nhan.Xuat();
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;
class Parent
{
public:
  Parent() { cout << "ham tao lop cha" << endl; }
  ~Parent() { cout << "ham huy lop cha" << endl; }
};

class Child : public Parent
{
public:
  Child() { cout << "ham tao lop con" << endl; }
  ~Child() { cout << "ham huy lop con" << endl; }
};

void ham(Child c) {}
  int main() {
    Child obj1;
    ham(obj1);  
    return 0;
  }

/** bài 4
 * vì class Child kế thừa đơn từ class Parent
 * lên khi khởi tạo đối tượng từ lớp Child sẽ 
 * được cấp phát bộ nhớ để khởi tạo cho lớp 
 * cha trước lên hàm tạo của lớp cha được gọi
 * sau đó hàm tạo của con được gọi. khi return 0
 * thì hàm huỷ lớp con được gọi sau đó mới gọi tới
 * hàm huỷ của lớp cha. Vì lớp con dẫn xuất lớp cha 
  */

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class KHACHHANG
{
private:
  string ten;

public:
  KHACHHANG(){}
  void nhap()
  {
    cout << "Nhap ten khach hang: ";
    cin >> ten;
  }
  void hien()
  {
    cout << "Ten khach hang: " << ten << endl;
  }

  string getTenKhachHang()
  {
    return ten;
  }
  float tinhTien() = 0;
};

class HOADON : public KHACHHANG
{
private:
  int soHieuCongTo;
  int soDienSuDung;
  static float giaDienBinhQuan;
public:
  HOADON() : KHACHHANG()
  {
    soHieuCongTo = 0;
    soDienSuDung = 0;
  }
  void nhap() override
  {
    KHACHHANG::nhap();
    cout << "Nhap so hieu cong to: ";
    cin >> soHieuCongTo;
    cout << "Nhap so dien su dung: ";
    cin >> soDienSuDung;
    cout << endl;
  }
  void hien() override
  {
    KHACHHANG::hien();
    cout << "So hieu cong to: " << soHieuCongTo << endl;
    cout << "So dien su dung: " << soDienSuDung << endl;
    cout << "Thanh tien: " << tinhTien() << endl;
  }
  float tinhTien() override
  {
    float thanhTien = soDienSuDung * giaDienBinhQuan + 0.1 * soDienSuDung * giaDienBinhQuan;
    return thanhTien;
  }
};

float HOADON::giaDienBinhQuan = 4000.0;

int main()
{
  vector<HOADON> danhSachHoaDon;
  int n;

  cout << "Nhap so luong hoa don: ";
  cin >> n;

  cin.ignore();

  for (int i = 0; i < n; i++)
  {
    HOADON hd;
    hd.nhap();
    danhSachHoaDon.push_back(hd);
  }

  // In danh sach hoa don ra man hinh
  for (int i = 0; i < danhSachHoaDon.size(); i++)
  {
    danhSachHoaDon[i].hien();
  }

  // Tinh tong tien thanh toan theo tung khach hang
  for (int i = 0; i < danhSachHoaDon.size(); i++)
  {
    string tenKhachHang = danhSachHoaDon[i].getTenKhachHang();
    double tongTien = danhSachHoaDon[i].tinhTien();

    for (int j = i + 1; j < danhSachHoaDon.size(); j++)
    {
      if (danhSachHoaDon[j].getTenKhachHang() == tenKhachHang)
      {
        tongTien += danhSachHoaDon[j].tinhTien();
        danhSachHoaDon.erase(danhSachHoaDon.begin() + j);
        j--;
      }
    }
    cout << "Tong tien thanh toan cua khach hang " << tenKhachHang << " la: " << tongTien << endl;
  }

  return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

class SANPHAM
{
private:
  string tenSP;
  float giaThanh;

public:
  void nhap()
  {
    cout << "nhap ten san pham: ";
    cin >> tenSP;
    cout << "nhap gia thanh san pham: ";
    cin >> giaThanh;
  }
  void xuat()
  {
    cout << "ten san pham : " << tenSP << endl;
    cout << "gia thanh san pham : " << giaThanh << endl;
  }
  string getTenSP()
  {
    return tenSP;
  }
  float getGiaThanh()
  {
    return giaThanh;
  }
};

class SANXUAT : public SANPHAM
{
  string tenCongNhan;
  int soSanPham;
  static float phuCap;

public:
  SANXUAT()
  {
  }
  void nhap()
  {
    SANPHAM::nhap();
    cout << "nhap ten cong nhan : ";
    cin >> tenCongNhan;
    cout << "nhap so san pham lam duoc : ";
    cin >> soSanPham;
  }
  void xuat()
  {
    SANPHAM::xuat();
    cout << "ten cong nhan : " << tenCongNhan << endl;
    cout << "so san pham lam duoc : " << soSanPham << endl;
  }

  void xuatDS()
  {
    cout << "  " << tenCongNhan << "           " << soSanPham << "      " << tinhLuong() << endl;
  }
  float tinhLuong()
  {
    return soSanPham * SANPHAM::getGiaThanh() * 0.05 + (soSanPham * SANPHAM::getGiaThanh() * 0.05 * phuCap / 100);
  }
};
float SANXUAT::phuCap = 5;

void nhapDSSanXuat(vector<SANXUAT> &sx)
{
  int n;
  cout << "nhap so luong san xuat muon nhap : ";
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    SANXUAT h;
    cout << "nhap hoa don thu " << i << " :" << endl;
    h.nhap();
    sx.push_back(h);
  }
}

void xuatDSSanXuat(vector<SANXUAT> &sx)
{
  cout << "Ten cong nhan|"
       << "San luong|"
       << "Luong" << endl;
  for (auto &i : sx)
  {
    i.xuatDS();
  }
}

vector<SANXUAT> congNhanLuongCaoNhat(vector<SANXUAT> &sx)
{
  vector<SANXUAT> result;
  SANXUAT tmax = sx[0];
  for (auto &cn : sx)
  {
    if (tmax.tinhLuong() < cn.tinhLuong())
    {
      tmax = cn;
      result.clear();
      result.push_back(cn);
    }
    else if (tmax.tinhLuong() == cn.tinhLuong())
    {
      tmax = cn;
      result.push_back(cn);
    }
  }
  return result;
}

main()
{
  vector<SANXUAT> sx, salary;
  nhapDSSanXuat(sx);
  xuatDSSanXuat(sx);
  salary = congNhanLuongCaoNhat(sx);
  cout << "Cac nhan vien co luong cao nhat: " << endl;
  xuatDSSanXuat(salary);
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

class Circle
{
private:
    double radius;

public:
    void setRadius(double r)
    {
        radius = r;
    }
    double getRadius()
    {
        return radius;
    }
    double getArea()
    {
        return 3.14 * radius * radius;
    }
    double getPerimeter()
    {
        return 2 * 3.14 * radius;
    }
};

class ThiSinh
{
public:
    string sbd;
    float toan;
    float hoa;
    float ly;
    float tongDiem;
    ThiSinh(string sbd, float toan, float hoa, float ly)
    {
        this->sbd = sbd;
        this->toan = toan;
        this->hoa = hoa;
        this->ly = ly;
        this->tongDiem = toan + hoa + ly;
    }
    bool operator<(const ThiSinh &other) const
    {
        return tongDiem < other.tongDiem;
    }
};

class tamGiac
{
private:
    double a, b, c;

public:
    tamGiac()
    {
        a = 0;
        b = 0;
        c = 0;
    }
    void nhap()
    {
        do
        {
            cout << "Nhap gia tri cac canh: ";
            cin >> a >> b >> c;
            if (a <= 0 || b <= 0 || c <= 0)
            {
                cout << "Gia tri cac canh phai la so duong, vui long nhap lai!" << endl;
            }
            else if (a + b <= c || a + c <= b || b + c <= a)
            {
                cout << "Day khong phai la 3 canh cua tam giac, vui long nhap lai!" << endl;
            }
        } while (a <= 0 || b <= 0 || c <= 0 || a + b <= c || a + c <= b || b + c <= a);
    }
    double tinhDT()
    {
        double p = (a + b + c) / 2.0;
        return sqrt(p * (p - a) * (p - b) * (p - c));
    }
    void kiemTraTG()
    {
        if (a == b && b == c)
        {
            cout << "Tam giac deu" << endl;
        }
        else if (a == b || a == c || b == c)
        {
            if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a)
            {
                cout << "Tam giac vuong can" << endl;
            }
            else
            {
                cout << "Tam giac can" << endl;
            }
        }
        else if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a)
        {
            cout << "Tam giac vuong" << endl;
        }
        else
        {
            cout << "Tam giac thuong" << endl;
        }
    }
    void hienThiTT()
    {
        cout << "Diện tích tam giác: " << tinhDT() << endl;
        kiemTraTG();
    }
};

class PhanSo
{
private:
    int ts, ms;

public:
    PhanSo()
    {
    }
    PhanSo(int t, int m)
    {
        ts = t;
        ms = m;
    }
    void nhap()
    {
        cout << "Nhap tu so: ";
        cin >> ts;
        cout << "Nhap mau so: ";
        cin >> ms;
    }
    void in()
    {
        cout << ts << "/" << ms << endl;
    }
    int ucln(int a, int b)
    {
        if (b == 0)
        {
            return a;
        }
        return ucln(b, a % b);
    }
    PhanSo cong(PhanSo b)
    {
        PhanSo c;
        c.ts = ts * b.ms + b.ts * ms;
        c.ms = ms * b.ms;
        return c;
    }
    PhanSo tru(PhanSo b)
    {
        PhanSo c;
        c.ts = ts * b.ms - b.ts * ms;
        c.ms = ms * b.ms;
        return c;
    }
    PhanSo nhan(PhanSo b)
    {
        PhanSo c;
        c.ts = ts * b.ts;
        c.ms = ms * b.ms;
        return c;
    }
    PhanSo chia(PhanSo b)
    {
        PhanSo c;
        c.ts = ts * b.ms;
        c.ms = ms * b.ts;
        return c;
    }
    bool laToiGian()
    {
        int u = ucln(ts, ms);
        if (u == 1)
        {
            return true;
        }
        return false;
    }
    void toiGian()
    {
        int u = ucln(ts, ms);
        ts /= u;
        ms /= u;
        cout << "Phan so toi gian: " << ts << "/" << ms << endl;
    }
    int soSanh(PhanSo b)
    {
        PhanSo c = tru(b);
        if (c.ts == 0)
        {
            return 0;
        }
        if (c.ts > 0)
        {
            return 1;
        }
        return -1;
    }
};

class soPhuc
{
private:
    double thuc, ao;

public:
    soPhuc() : thuc(0), ao(0) {}
    soPhuc(double thuc, double ao) : thuc(thuc), ao(ao) {}
    void nhapSoPhuc()
    {
        cout << "Nhap phan thuc: ";
        cin >> thuc;
        cout << "Nhap phan ao: ";
        cin >> ao;
    }
    void inSoPhuc()
    {
        cout << thuc << (ao > 0 ? " + " : " - ") << abs(ao) << "i" << endl;
    }
    soPhuc operator+(soPhuc other)
    {
        soPhuc result;
        result.thuc = thuc + other.thuc;
        result.ao = ao + other.ao;
        return result;
    }
    soPhuc operator-(soPhuc other)
    {
        soPhuc result;
        result.thuc = thuc - other.thuc;
        result.ao = ao - other.ao;
        return result;
    }
    soPhuc operator*(soPhuc other)
    {
        soPhuc result;
        result.thuc = thuc * other.thuc - ao * other.ao;
        result.ao = thuc * other.ao + ao * other.thuc;
        return result;
    }
};

int main()
{
    // Bai1
    cout << "Bai 1: \n";
    Circle circle;
    double r;
    cout << "Enter the radius of the circle: ";
    cin >> r;
    circle.setRadius(r);
    cout << "The area of the circle is: " << circle.getArea() << endl;
    cout << "The perimeter of the circle is: " << circle.getPerimeter() << endl;

    // Bai2
    cout << "Bai 2: \n";
    vector<ThiSinh> dsThiSinh;
    int n;
    cout << "Nhap so luong thi sinh: ";
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string sbd;
        float toan, hoa, ly;
        cout << "Nhap thong tin thi sinh " << i + 1 << endl;
        cout << "So bao danh: ";
        cin >> sbd;
        cout << "Diem toan: ";
        cin >> toan;
        cout << "Diem hoa: ";
        cin >> hoa;
        cout << "Diem ly: ";
        cin >> ly;
        ThiSinh ts(sbd, toan, hoa, ly);
        dsThiSinh.push_back(ts);
    }
    sort(dsThiSinh.begin(), dsThiSinh.end());
    ThiSinh tsMax = dsThiSinh.back();
    cout << "Danh sach cac thi sinh co tong diem tren 18:\n";
    for (int i = 0; i < dsThiSinh.size(); i++)
    {
        ThiSinh ts = dsThiSinh[i];
        if (ts.tongDiem > 18)
        {
            cout << ts.sbd << " - Toan: " << ts.toan << " - Hoa: " << ts.hoa << " - Ly: " << ts.ly << " - Tong diem: " << ts.tongDiem << endl;
        }
    }
    // Bai3
    cout << "Bai 3: \n";
    tamGiac tg;
    tg.nhap();
    tg.hienThiTT();

    // Bai4
    cout << "Bai 4: \n";
    PhanSo a, b, c;
    cout << "Nhap phan so a:\n";
    a.nhap();
    cout << "Nhap phan so b:\n";
    b.nhap();
    cout << "Phan so a: ";
    a.in();
    cout << "Phan so b: ";
    b.in();
    c = a.cong(b);
    cout << "Tong hai phan so: ";
    c.in();
    cout << endl;
    c = a.tru(b);
    cout << "Hieu hai phan so: ";
    c.in();
    cout << endl;
    c = a.nhan(b);
    cout << "Tich hai phan so: ";
    c.in();
    cout << endl;
    c = a.chia(b);
    cout << "Thuong hai phan so: ";
    c.in();
    cout << endl;
    if (a.laToiGian() == true)
    {
        cout << "A la phan so toi gian ";
        cout << endl;
    }
    else
    {
        cout << "A khong la phan so toi gian ";
        cout << endl;
    }
    if (b.laToiGian() == true)
    {
        cout << "B la phan so toi gian ";
        cout << endl;
    }
    else
    {
        cout << "B khong la phan so toi gian ";
        cout << endl;
    }
    cout << endl;
    a.toiGian();
    cout << endl;
    b.toiGian();
    cout << endl;

    // Bai5
    cout << "Bai 5: \n";
    soPhuc a5, b5;
    a5.nhapSoPhuc();
    b5.nhapSoPhuc();
    cout << "Tong hai so phuc la: ";
    (a5 + b5).inSoPhuc();
    cout << "Hieu hai so phuc la: ";
    (a5 - b5).inSoPhuc();
    cout << "Tich hai so phuc la: ";
    (a5 * b5).inSoPhuc();
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
using namespace std;

class PhanSo
{
private:
    int ts, ms;

public:
    PhanSo()
    {
    }
    PhanSo(int ts, int ms)
    {
        this->ts = ts;
        this->ms = ms;
    }
    void nhap()
    {
        cout << "Nhap tu so: ";
        cin >> ts;
        cout << "Nhap mau so: ";
        cin >> ms;
        while (ms == 0)
        {
            cout << "Mau so khong the bang 0. Nhap lai mau so: ";
            cin >> ms;
        }
    }
    void in()
    {
        cout << ts << "/" << ms;
    }
    int UCLN(int a, int b)
    {
        if (a == 0 || b == 0)
        {
            return a + b;
        }
        while (a != b)
        {
            if (a > b)
            {
                a = a - b;
            }
            else
            {
                b = b - a;
            }
        }
        return a;
    }
    bool laToiGian()
    {
        int ucln = UCLN(ts, ms);
        return (ucln == 1);
    }
    void toiGian()
    {
        int ucln = UCLN(ts, ms);
        ts /= ucln;
        ms /= ucln;
        cout << "Phan so toi gian: " << ts << "/" << ms << endl;
    }
    PhanSo operator+(PhanSo const &ps)
    {
        PhanSo tong;
        tong.ts = ts * ps.ms + ms * ps.ts;
        tong.ms = ms * ps.ms;
        return tong;
    }
    PhanSo operator-(PhanSo const &ps)
    {
        PhanSo hieu;
        hieu.ts = ts * ps.ms - ms * ps.ts;
        hieu.ms = ms * ps.ms;
        return hieu;
    }
    PhanSo operator*(PhanSo const &ps)
    {
        PhanSo tich;
        tich.ts = ts * ps.ts;
        tich.ms = ms * ps.ms;
        return tich;
    }
    PhanSo operator/(PhanSo const &ps)
    {
        PhanSo thuong;
        thuong.ts = ts * ps.ms;
        thuong.ms = ms * ps.ts;
        return thuong;
    }
    bool operator==(PhanSo const &ps)
    {
        PhanSo ps1 = *this;
        PhanSo ps2 = ps;
        ps1.toiGian();
        ps2.toiGian();
        return (ps1.ts == ps2.ts && ps1.ms == ps2.ms);
    }
};

class SoPhuc
{
private:
    float thuc, ao;

public:
    SoPhuc()
    {
    }
    SoPhuc(float r, float i)
    {
        thuc = r;
        ao = i;
    }
    float getThuc()
    {
        return thuc;
    }

    float getAo()
    {
        return ao;
    }

    void setThuc(float r)
    {
        thuc = r;
    }

    void setAo(float i)
    {
        ao = i;
    }
    void nhapSoPhuc()
    {
        cout << "Nhap phan thuc: ";
        cin >> thuc;
        cout << "Nhap phan ao: ";
        cin >> ao;
    }
    void inSoPhuc()
    {
        if (ao < 0)
        {
            cout << thuc << " - " << -ao << "i" << endl;
        }
        else
        {
            cout << thuc << " + " << ao << "i" << endl;
        }
    }
    SoPhuc operator+(SoPhuc const &obj)
    {
        SoPhuc res;
        res.thuc = thuc + obj.thuc;
        res.ao = ao + obj.ao;
        return res;
    }
    SoPhuc operator-(SoPhuc const &obj)
    {
        SoPhuc res;
        res.thuc = thuc - obj.thuc;
        res.ao = ao - obj.ao;
        return res;
    }
    SoPhuc operator*(SoPhuc const &obj)
    {
        SoPhuc res;
        res.thuc = thuc * obj.thuc - ao * obj.ao;
        res.ao = thuc * obj.ao + ao * obj.thuc;
        return res;
    }
    friend istream &operator>>(istream &is, SoPhuc &obj)
    {
        cout << "Nhap phan thuc: ";
        is >> obj.thuc;
        cout << "Nhap phan ao: ";
        is >> obj.ao;
        return is;
    }
    friend ostream &operator<<(ostream &os, const SoPhuc &obj)
    {
        if (obj.ao < 0)
        {
            os << obj.thuc << " - " << -obj.ao << "i" << endl;
        }
        else
        {
            os << obj.thuc << " + " << obj.ao << "i" << endl;
        }
        return os;
    }
};

class numberList
{
private:
    vector<int> nums;

public:
    numberList()
    {
        nums.clear();
    }
    void addition(int x)
    {
        if (x % 2 == 1)
        {
            nums.push_back(x);
        }
    }
    void printList() const
    {
        cout << "Danh sach cac so le la: ";
        for (int i = 0; i < nums.size(); i++)
        {
            cout << nums[i] << " ";
        }
        cout << endl;
    }
    void clear()
    {
        nums.clear();
    }
    int length()
    {
        return nums.size();
    }
    numberList operator+(numberList const &obj)
    {
        numberList res;
        res.nums = nums;
        for (int i = 0; i < obj.nums.size(); i++)
        {
            res.addition(obj.nums[i]);
        }
        return res;
    }
    numberList operator+(int x)
    {
        numberList res;
        res.nums = nums;
        res.addition(x);
        return res;
    }
    numberList operator-(int x)
    {
        numberList res;
        for (int i = 0; i < nums.size(); i++)
        {
            if (nums[i] != x)
            {
                res.addition(nums[i]);
            }
        }
        return res;
    }
    int operator[](int i)
    {
        return nums[i];
    }
};

int main()
{
    // Bai1
    cout << "Bai 1: \n";
    PhanSo a, b, c;
    cout << "Nhap phan so a:\n";
    a.nhap();
    cout << "Nhap phan so b:\n";
    b.nhap();
    cout << "Phan so a: ";
    a.in();
    cout << endl;
    cout << "Phan so b: ";
    b.in();
    cout << endl;
    c = a + b;
    cout << "Tong hai phan so: ";
    c.in();
    cout << endl;
    c = a - b;
    cout << "Hieu hai phan so: ";
    c.in();
    cout << endl;
    c = a * b;
    cout << "Tich hai phan so: ";
    c.in();
    cout << endl;
    c = a / b;
    cout << "Thuong hai phan so: ";
    c.in();
    cout << endl;
    if (a.laToiGian() == true)
    {
        cout << "A la phan so toi gian ";
        cout << endl;
    }
    else
    {
        cout << "A khong la phan so toi gian ";
        cout << endl;
    }
    if (b.laToiGian() == true)
    {
        cout << "B la phan so toi gian ";
        cout << endl;
    }
    else
    {
        cout << "B khong la phan so toi gian ";
        cout << endl;
    }
    a.toiGian();
    b.toiGian();

    // Bai2
    cout << "Bai 2: \n";
    SoPhuc a2, b2, c2;
    cout << "Nhap so phuc a: " << endl;
    cin >> a2;
    cout << "Nhap so phuc b: " << endl;
    cin >> b2;
    c2 = a2 + b2;
    cout << "a + b = " << c2 << endl;
    c2 = a2 - b2;
    cout << "a - b = " << c2 << endl;
    c2 = a2 * b2;
    cout << "a * b = " << c2 << endl;

    // Bai3
    cout << "Bai 3: \n";
    numberList list1, list2, list3;
    list1.addition(3);
    list1.addition(5);
    list1.addition(7);
    cout << "List 1:" << endl;
    list1.printList();
    cout << "so luong so trong list la " << list1.length() << endl;
    list2.addition(9);
    list2.addition(11);
    cout << "List 2:" << endl;
    list2.printList();
    list3 = list1 + list2;
    cout << "List 3 (List 1 + List 2):" << endl;
    list3.printList();
    list3 = list3 + 13;
    cout << "List 3 + 13:" << endl;
    list3.printList();
    list3.clear();
    cout << "List 3 sau khi xoa:" << endl;
    list3.printList();
    cout << "Gia tri tai index 1 = ";
    cout << list1[1];
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<vector>
#include<string>
using namespace std;

class KHACHHANG {
    public:
        string ten;
    public:
        KHACHHANG(){
        }
        void nhap(){
            cout << "Nhap ten khach hang: ";
            getline(cin, ten);
        }
        void hien(){
            cout << "Ten khach hang: " << ten << endl;
        }
};

class HOADON: public KHACHHANG {
    private:
        int soHieuCongTo;
        int soDienSuDung;
        static float giaDienBinhQuan;
    public:
        HOADON(){
            soHieuCongTo = 0;
            soDienSuDung = 0;
        }
        void nhap(){
            KHACHHANG::nhap();
            cout << "Nhap so hieu cong to: ";
            cin >> soHieuCongTo;
            cout << "Nhap so dien su dung: ";
            cin >> soDienSuDung;
            cin.ignore();
            cout << endl;
        }
        void hien(){
            KHACHHANG::hien();
            cout << "So hieu cong to: " << soHieuCongTo << endl;
            cout << "So dien su dung: " << soDienSuDung << endl;
            cout << "Tien dien: " << tinhTien() << endl;
        }
        float tinhTien(){
           return soDienSuDung * giaDienBinhQuan + 0.1 * soDienSuDung * giaDienBinhQuan;
        }
};

float HOADON::giaDienBinhQuan = 4000;

int main(){
    vector<HOADON> dsHoaDon;
    int n;
    cout << "Nhap so luong hoa don: ";
    cin >> n;
    cin.ignore();
    dsHoaDon.resize(n);
    for(int i = 0; i < n; i++){
        cout << "Nhap thong tin hoa don " << i + 1 << ":" << endl;
        dsHoaDon[i].nhap();
    }
    cout << "\n\n";
    for(int i = 0; i < n; i++){
        cout << "Hoa don " << i + 1 << ":" << endl;
        dsHoaDon[i].hien();
        cout << "\n\n";
    }
    cout << "Tong tien thanh toan theo tung khach hang: " << endl;
    for(int i = 0; i < n; i++){
        int tongTien = 0;
        for(int j = 0; j < n; j++){
            if(dsHoaDon[j].ten == dsHoaDon[i].ten){
                tongTien += dsHoaDon[j].tinhTien();
            }
        }
        cout << "Khach hang " << dsHoaDon[i].ten << " co tong tien thanh toan la: " << tongTien << endl;
    }
    return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<string>
#include<vector>
using namespace std;

class SANPHAM {
    protected:
        string tenSanPham;
        float giaThanh;
    public:
        SANPHAM(){
        }
        void nhap(){
            cout << "Nhap ten san pham: ";
            getline(cin, tenSanPham);
            cout << "Nhap gia thanh: ";
            cin >> giaThanh;
            cin.ignore();
        }
        void hien(){
            cout << "Ten san pham: " << tenSanPham << endl;
            cout << "Gia thanh: " << giaThanh << endl;
        }
        float getGiaThanh(){
            return giaThanh;
        }
};

class SANXUAT : public SANPHAM {
    public:
        string tenCongNhan;
        int soLuongSanPham;
        static float phuCapLuongSanPham;
    public:
        SANXUAT(){
            tenCongNhan = "";
            soLuongSanPham = 0;
        }
        void nhap(){
            SANPHAM::nhap();
            cout << "Nhap ten cong nhan: ";
            getline(cin, tenCongNhan);
            cout << "Nhap so luong san pham: ";
            cin >> soLuongSanPham;
            cin.ignore();
        }
        void hien(){
            SANPHAM::hien();
            cout << "Ten cong nhan: " << tenCongNhan << endl;
            cout << "So luong san pham: " << soLuongSanPham << endl;
            cout << "Luong: " << tinhLuong() << endl;
        }
        float tinhLuong(){
            return soLuongSanPham * 0.05 * SANPHAM::getGiaThanh() + soLuongSanPham * phuCapLuongSanPham;
        }
};

float SANXUAT::phuCapLuongSanPham = 500;

int main(){
    vector<SANXUAT> danhSach;
    int n;
    cout << "Nhap so luong san pham: ";
    cin >> n;
    cin.ignore();
    danhSach.resize(n);
    for(int i = 0; i < n; i++){
        cout << "Nhap thong tin san pham " << i + 1 << ":" << endl;
        danhSach[i].nhap();
        cout << endl;
    }
    cout << "Danh sach san pham: \n" << endl;
    for(int i = 0; i < n; i++){
        cout << "San pham " << i + 1 << ":" << endl;
        danhSach[i].hien();
        cout << endl;
    }

    float maxLuong = 0;
    for(int i = 0; i < n; i++){
        if(danhSach[i].tinhLuong() > maxLuong)
            maxLuong = danhSach[i].tinhLuong();
    }
    cout << "\n\nCac cong nhan co tong luong cao nhat: \n" << endl;
    for(int i = 0; i < n; i++){
        if(danhSach[i].tinhLuong() == maxLuong){
            cout << danhSach[i].tenCongNhan << endl;
        }
    }
    return 0;
}

# data[].attributes.attachment_link.readable_text
// Bai 1: Hien thi chu vi dien tich hinh tron 
#include <iostream> 
#include <math.h>
#define PI 3.14
using namespace std; 
class hinhtron
{
   private:
        float r;
   public:
      void nhap();
        float chuvi();
      	float dientich();
        void in();
};
// Dinh nghia ham thanh vien ben ngoai khai bao lop  
void hinhtron::nhap()
{
  cout<<"Nhap vao ban kinh:";
  cin>>r;
}

float hinhtron::chuvi()
{
  return (2*PI*r);
}

float hinhtron::dientich()
{
  return (PI*pow(r,2));
}

void hinhtron::in()
{
    cout<<"Chu vi hinh tron la:"<<chuvi()<<endl;
   cout<<"Dien tich hinh tron la:"<<dientich()<<endl;
}
int  main()
{
  hinhtron ht;
  ht.nhap();
  ht.in();
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;

class SoPhuc
{
  int thuc, ao;

public:
  SoPhuc()
  {
    thuc = 0;
    ao = 0;
  }
  SoPhuc(int t, int a) { thuc = t, ao = a; }
  void nhapSoPhuc()
  {
    cout << "thuc: ";
    cin >> thuc;
    cout << "ao: ";
    cin >> ao;
  }
  void inSoPhuc()
  {
    cout << thuc << " + " << ao << "*j";
  }
  SoPhuc operator+(SoPhuc &p2)
  {
    int tThuc = thuc + p2.thuc;
    int aAo = ao + p2.ao;
    return SoPhuc(tThuc, aAo);
  }
  SoPhuc operator-(SoPhuc &p)
  {
    float t = thuc - p.thuc;
    float a = ao - p.ao;
    return SoPhuc(t, a);
  }
  SoPhuc operator*(SoPhuc &p)
  {
    float t = thuc * p.thuc - ao * p.ao;
    float a = ao * p.thuc + thuc * p.ao;
    return SoPhuc(t, a);
  }
};

main()
{
  SoPhuc p1(2, 3), p2(4, 5), p3;
  p3 = p1 + p2;
  cout << "Tong hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  p3 = p1 - p2;
  cout << "Hieu hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  p3 = p1 * p2;
  cout << "Tich hai so phuc: ";
  p3.inSoPhuc();
  cout << endl;
  return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include <vector>
using namespace std;

class KHACHHANG{
	public :
		string tenKh;
	public :
		void nhap(){
			cout<<"Nhap ten khach hang : ";
			cin>>tenKh;
		}	
		void hien(){
			cout<<"Ten khach hang la : "<<tenKh<<endl;
		}
		string getTen(){
			return tenKh;
		}
};

class HOADON : public KHACHHANG{
	public :
		double soCt , soDien;
		static double giadien;
	public :
		HOADON(){
			
		}
		void nhap(){
			KHACHHANG::nhap();
			cout<<"Nhap so dien su dung : ";
			cin>>soDien;
		}
		void hien(){
			KHACHHANG::hien();
			cout<<"Tong tien la : "<<tinhtoan()<<endl;
		}
		double tinhtoan(){
			double tienDien = soDien * giadien;
			double tt = tienDien + 0.1*(tienDien);
			return tt;
		}
};
double HOADON::giadien = 4500;
int main(){
	vector<HOADON> kh;
	int n;
    cout<<"Nhap so luong khach hang : ";
    cin>>n;
    for(int i = 0; i < n; i++){
        HOADON hd;
		hd.nhap();
		kh.push_back(hd);
	}
	cout<<"--------------Danh sach cac khach hang la ------------"<<endl;
	for(int i = 0; i < kh.size(); i++){
		
		string tenKh = kh[i].getTen();
    	double tt = kh[i].tinhtoan();
    	
		for(int j = i+1 ;j<kh.size();j++){
			if(kh[j].getTen() == tenKh ){
				tt += kh[i].tinhtoan();
				kh.erase(kh.begin() + j);
        		j--;
			}
		} 
        cout << "Tong tien thanh toan cua khach hang " << tenKh << " la: " << tt << endl;
    }
    return 0;
	
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
using namespace std;

class KHACHHANG
{
private:
    string tenKH;

public:
    KHACHHANG() {}

    KHACHHANG(string tenKH)
    {
        this->tenKH = tenKH;
    }

    string getTenKH()
    {
        return tenKH;
    }

    void nhap()
    {
        cout << "Nhap ten khach hang: ";
        cin >> tenKH;
    }

    void hien()
    {
        cout << "Ten khach hang: " << tenKH << endl;
    }
};

class HOADON : public KHACHHANG
{
private:
    int soCongTo, soDienSuDung;
    static float giaDienBinhQuan;

public:
    HOADON() : KHACHHANG() {}

    HOADON(string tenKH, int soCongTo, int soDienSuDung) : KHACHHANG(tenKH)
    {
        this->soCongTo = soCongTo;
        this->soDienSuDung = soDienSuDung;
    }

    void nhap()
    {
        KHACHHANG::nhap();
        cout << "Nhap so cong to: ";
        cin >> soCongTo;
        cout << "Nhap so dien su dung: ";
        cin >> soDienSuDung;
    }

    void hien()
    {
        KHACHHANG::hien();
        cout << "So cong to: " << soCongTo << endl;
        cout << "So dien su dung: " << soDienSuDung << endl;
        cout << "Thanh tien: " << tinhTien() << " VND" << endl;
    }

    float tinhTien()
    {
        return soDienSuDung * giaDienBinhQuan + soDienSuDung * giaDienBinhQuan * 0.1;
    }
};

float HOADON::giaDienBinhQuan = 4000;

int main()
{
    int nHoaDon;
    cout << "Nhap so luong hoa don: ";
    cin >> nHoaDon;

    //    khoi tao danh sach hoa don
    vector<HOADON> dsHoaDon(nHoaDon);

    for (int i = 0; i < nHoaDon; i++)
    {
        cout << endl;
        cout << "Nhap thong tin hoa don " << i + 1 << ":" << endl;
        dsHoaDon[i].nhap();
    }

    cout << "Danh sach hoa don:" << endl;
    for (int i = 0; i < nHoaDon; i++)
    {
        cout << endl;
        dsHoaDon[i].hien();
        cout << endl;
    }

    // khoi tao danh sach de tim ten khach hang trung
    vector<string> dsTenKhachHang;
    for (int i = 0; i < nHoaDon; i++)
    {
        // lay ten khach hang
        string tenKH = dsHoaDon[i].KHACHHANG::getTenKH();
        bool KHTonTai = false;
        for (int j = 0; j < dsTenKhachHang.size(); j++)
        {
            if (dsTenKhachHang[j] == tenKH)
            {
                KHTonTai = true;
                break;
            }
        }
        if (!KHTonTai)
        {
            dsTenKhachHang.push_back(tenKH);
        }
    }
    cout << "Tong tien thanh toan theo tung khach hang:" << endl;
    for (int i = 0; i < dsTenKhachHang.size(); i++)
    {
        float tongTien = 0;
        // kiem tra khach hang trung ten de cong tien
        for (int j = 0; j < nHoaDon; j++)
        {
            if (dsHoaDon[j].KHACHHANG::getTenKH() == dsTenKhachHang[i])
            {
                tongTien += dsHoaDon[j].tinhTien();
            }
        }
        cout << dsTenKhachHang[i] << ": " << tongTien << " VND" << endl;
    }

    return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class SANPHAM {
protected:
    string tenSanPham;
    double giaThanh;
public:
    void nhap() {
        cout << "Nhap ten san pham: ";
        cin.ignore();
        getline(cin, tenSanPham);
        cout << "Nhap gia thanh: ";
        cin >> giaThanh;
    }

    void hien() {
        cout << "Ten san pham: " << tenSanPham << endl;
        cout << "Gia thanh: " << giaThanh << endl;
    }
};

class SANXUAT : public SANPHAM {
private:
    string tenCongNhan;
    int soLuongSanPham;
    static double phuCapLuongSanPham; // thuoc tinh tinh
public:
    SANXUAT() {}

    void nhap() {
        SANPHAM::nhap();
        cout << "Nhap ten cong nhan: ";
        cin.ignore();
        getline(cin, tenCongNhan);
        cout << "Nhap so luong san pham: ";
        cin >> soLuongSanPham;
    }

    void hien() {
        SANPHAM::hien();
        cout << "Ten cong nhan: " << tenCongNhan << endl;
        cout << "So luong san pham: " << soLuongSanPham << endl;
    }

    double tinhLuong() {
        return soLuongSanPham * giaThanh * 0.05 + phuCapLuongSanPham;
    }

    static void setPhuCapLuongSanPham(double phuCap) {
        phuCapLuongSanPham = phuCap;
    }

    static double getPhuCapLuongSanPham() {
        return phuCapLuongSanPham;
    }
    string getTenCongNhan(){
    	return tenCongNhan;
	} 
};

double SANXUAT::phuCapLuongSanPham = 0;

int main() {
    int N;
    cout << "Nhap so luong doi tuong SANXUAT: ";
    cin >> N;

    vector<SANXUAT> dsSanXuat(N);

    cout << "Nhap thong tin cho " << N << " doi tuong SANXUAT:" << endl;
    for (int i = 0; i < N; i++) {
        cout << "Nhap thong tin doi tuong thu " << i + 1 << ":" << endl;
        dsSanXuat[i].nhap();
    }

    double tongLuong = 0;
    for (int i = 0; i < N; i++) {
        tongLuong += dsSanXuat[i].tinhLuong();
    }
    cout << "Tong luong cua tat ca cong nhan: " << tongLuong;
    
    // Tim cong nhan co tong luong cao nhat
	double maxLuong = dsSanXuat[0].tinhLuong();
	int maxIndex = 0;
	
	for (int i = 1; i < N; i++) {
	    if (dsSanXuat[i].tinhLuong() > maxLuong) {
	        maxLuong = dsSanXuat[i].tinhLuong();
	        maxIndex = i;
	    }
	}

	cout << "Ten cong nhan co tong luong cao nhat: " << dsSanXuat[maxIndex].getTenCongNhan() << endl;

	return 0;
}



# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class SANPHAM
{
private:
    string tenSP;
    float giaThanh;

public:
    SANPHAM() {}

    SANPHAM(string tenSP, float giaThanh)
    {
        this->tenSP = tenSP;
        this->giaThanh = giaThanh;
    }

    string getTenSP()
    {
        return tenSP;
    }

    float getGiaThanh()
    {
        return giaThanh;
    }

    void Nhap()
    {
        cout << "Nhap ten san pham: ";
        cin >> tenSP;
        cout << "Nhap gia thanh: ";
        cin >> giaThanh;
    }

    void Hien()
    {
        cout << "Ten san pham: " << tenSP << endl;
        cout << "Gia thanh: " << giaThanh << endl;
    }
};

class SANXUAT : public SANPHAM
{
private:
    string tenCN;
    int soLuongSP;
    static float phuCap;

public:
    SANXUAT() {}

    SANXUAT(string tenCN, int soLuongSP, float phuCap)
    {
        this->tenCN = tenCN;
        this->soLuongSP = soLuongSP;
        this->phuCap = phuCap;
    }

    string getTenCN()
    {
        return tenCN;
    }

    void Nhap()
    {
        SANPHAM::Nhap();
        cout << "Nhap ten cong nhan: ";
        cin >> tenCN;
        cout << "Nhap so luong san pham: ";
        cin >> soLuongSP;
    }

    void Hien()
    {
        SANPHAM::Hien();
        cout << "Ten cong nhan: " << tenCN << endl;
        cout << "So luong san pham: " << soLuongSP << endl;
    }

    float TinhLuong()
    {
        return soLuongSP * 0.05 * getGiaThanh() + phuCap;
    }

    //    static void setPhuCap()
    //    {
    //        cout << "Nhap phu cap: ";
    //        cin >> phuCap;
    //        phuCap /= 100;
    //    }
    //
    //    static float getPhuCap()
    //    {
    //        return phuCap;
    //    }
};

float SANXUAT::phuCap = 0.01;

int main()
{
    int nSanXuat;
    cout << "Nhap so luong doi tuong san xuat: ";
    cin >> nSanXuat;

    vector<SANXUAT> dsSanXuat(nSanXuat);

    for (int i = 0; i < nSanXuat; i++)
    {
        cout << endl;
        cout << "Nhap thong tin doi tuong san xuat thu " << i + 1 << ":" << endl;
        dsSanXuat[i].Nhap();
    }

    cout << "\nDanh sach doi tuong san xuat:\n";
    for (int i = 0; i < nSanXuat; i++)
    {
        cout << endl;
        dsSanXuat[i].Hien();
        cout << endl;
    }

    vector<string> dsTenCN;
    for (int i = 0; i < nSanXuat; i++)
    {
        string tenCN = dsSanXuat[i].SANXUAT::getTenCN();
        bool CNTonTai = false;
        for (int j = 0; j < dsTenCN.size(); j++)
        {
            if (dsTenCN[j] == tenCN)
            {
                CNTonTai = true;
                break;
            }
        }
        if (!CNTonTai)
        {
            dsTenCN.push_back(tenCN);
        }
    }
    vector<float> dsLuong;
    cout << "Tong luong theo tung cong nhan:" << endl;
    for (int i = 0; i < dsTenCN.size(); i++)
    {
        float tongTien = 0;
        for (int j = 0; j < nSanXuat; j++)
        {
            if (dsSanXuat[j].SANXUAT::getTenCN() == dsTenCN[i])
            {
                tongTien += dsSanXuat[j].TinhLuong();
            }
        }
        dsLuong.push_back(tongTien);
        cout << dsTenCN[i] << ": " << tongTien << " VND" << endl;
    }
    float luongCaoNhat = *max_element(dsLuong.begin(), dsLuong.end());
    cout << "\nCong nhan co luong cao nhat: ";
    cout << luongCaoNhat << " VND" << endl;

    return 0;
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<string>
using namespace std;
class KhachHang{
	private:
		string TenKH;
	public:
		KhachHang(){};
		void Nhap();
		void Xuat();
		string getTenKH(){
			return TenKH;
		}
};

class HoaDon:public KhachHang{
	private:
		string SoHieuCongTo;
		float SoDien;
		static float GiaDien;
		
	public:
		HoaDon(){}
		void Nhap1();
		void Xuat1();
		float TinhToan();
};

void KhachHang::Nhap(){
	cout<<"Nhap ten khach hang : "; cin>>TenKH;
}

void KhachHang::Xuat(){
	cout<<"Ten khach hang : "<<TenKH<<endl;
}

void HoaDon::Nhap1(){
	KhachHang::Nhap();
	cout<<"So hieu cong to : "; cin>>SoHieuCongTo;
	cout<<"Nhap so dien da SD : "; cin>>SoDien;
}

void HoaDon::Xuat1(){
	KhachHang::Xuat();
	cout<<"So hieu cong to : "<<SoHieuCongTo<<endl;
	cout<<"So dien : "<<SoDien<<endl;
	cout<<"Tong tien : "<<TinhToan()<<endl;
}
float HoaDon::GiaDien = 3000.0;

float HoaDon::TinhToan(){
	float TongTien=0;
	TongTien = (SoDien * GiaDien) + (SoDien * GiaDien)*0.1;
	return TongTien;
}

int main(){
	HoaDon hd;
	int n;
	HoaDon DSHoaDon[50];
	cout<<"Nhap so luong hoa don : "; cin>>n;
	for(int i=0;i<n;i++){
		DSHoaDon[i].Nhap1();
	}
	
	for(int i=0;i<n;i++){
		cout<<"\nThong tin hoa don "<<i+1<<endl;
		DSHoaDon[i].Xuat1();
	}
	
	cout<<"*Tong tien hoa don : "<<endl;
	for(int i=0;i<n;i++){
		float Tong=0;
		for(int j=0;j<n;j++){
			if(DSHoaDon[j].getTenKH() == DSHoaDon[i].getTenKH()){
				Tong+=DSHoaDon[j].TinhToan();
			}
		}
		cout<<"Khach hang : "<<DSHoaDon[i].getTenKH()<<" - Tong hoa don = "<<Tong<<endl;
	}
	return 0;
}

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;
class Parent
{
public:
  Parent() { cout << "ham tao lop cha" << endl; }
  ~Parent() { cout << "ham huy lop cha" << endl; }
};

class Child : public Parent
{
public:
  Child() { cout << "ham tao lop con" << endl; }
  ~Child() { cout << "ham huy lop con" << endl; }
};

void ham(Child c) {}
  int main() {
    Child obj1;
    ham(obj1);  
    return 0;
  }

# data[].attributes.attachment_link.readable_text

#include<iostream>
#include <vector>
using namespace std;

class KHACHHANG{
	public :
		string tenKh;
	public :
		void nhap(){
			cout<<"Nhap ten khach hang : ";
			cin>>tenKh;
		}	
		void hien(){
			cout<<"Ten khach hang la : "<<tenKh<<endl;
		}
		string getTen(){
			return tenKh;
		}
};

class HOADON : public KHACHHANG{
	public :
		double soCt , soDien;
		static double giadien;
	public :
		HOADON(){
			
		}
		void nhap(){
			KHACHHANG::nhap();
			cout<<"Nhap so dien su dung : ";
			cin>>soDien;
		}
		void hien(){
			KHACHHANG::hien();
			cout<<"Tong tien la : "<<tinhtoan()<<endl;
		}
		double tinhtoan(){
			double tienDien = soDien * giadien;
			double tt = tienDien + 0.1*(tienDien);
			return tt;
		}
};
double HOADON::giadien = 4500;
int main(){
	vector<HOADON> kh;
	int n;
    cout<<"Nhap so luong khach hang : ";
    cin>>n;
    for(int i = 0; i < n; i++){
        HOADON hd;
		hd.nhap();
		kh.push_back(hd);
	}
	cout<<"--------------Danh sach cac khach hang la ------------"<<endl;
	for(int i = 0; i < kh.size(); i++){
		
		string tenKh = kh[i].getTen();
    	double tt = kh[i].tinhtoan();
    	
		for(int j = i+1 ;j<kh.size();j++){
			if(kh[j].getTen() == tenKh ){
				tt += kh[i].tinhtoan();
				kh.erase(kh.begin() + j);
        		j--;
			}
		} 
        cout << "Tong tien thanh toan cua khach hang " << tenKh << " la: " << tt << endl;
    }
    return 0;
	
}

    

# data[].attributes.attachment_link.readable_text

#include<iostream>
#include<string>
#include<vector>
using namespace std;

class SANPHAM {
    protected:
        string tenSanPham;
        float giaThanh;
    public:
        SANPHAM(){
        }
        void nhap(){
            cout << "Nhap ten san pham: ";
            getline(cin, tenSanPham);
            cout << "Nhap gia thanh: ";
            cin >> giaThanh;
            cin.ignore();
        }
        void hien(){
            cout << "Ten san pham: " << tenSanPham << endl;
            cout << "Gia thanh: " << giaThanh << endl;
        }
        float getGiaThanh(){
            return giaThanh;
        }
};

class SANXUAT : public SANPHAM {
    public:
        string tenCongNhan;
        int soLuongSanPham;
        static float phuCapLuongSanPham;
    public:
        SANXUAT(){
            tenCongNhan = "";
            soLuongSanPham = 0;
        }
        void nhap(){
            SANPHAM::nhap();
            cout << "Nhap ten cong nhan: ";
            getline(cin, tenCongNhan);
            cout << "Nhap so luong san pham: ";
            cin >> soLuongSanPham;
            cin.ignore();
        }
        void hien(){
            SANPHAM::hien();
            cout << "Ten cong nhan: " << tenCongNhan << endl;
            cout << "So luong san pham: " << soLuongSanPham << endl;
            cout << "Luong: " << tinhLuong() << endl;
        }
        float tinhLuong(){
            return soLuongSanPham * 0.05 * SANPHAM::getGiaThanh() + soLuongSanPham * phuCapLuongSanPham;
        }
};

float SANXUAT::phuCapLuongSanPham = 500;

int main(){
    vector<SANXUAT> danhSach;
    int n;
    cout << "Nhap so luong san pham: ";
    cin >> n;
    cin.ignore();
    danhSach.resize(n);
    for(int i = 0; i < n; i++){
        cout << "Nhap thong tin san pham " << i + 1 << ":" << endl;
        danhSach[i].nhap();
        cout << endl;
    }
    cout << "Danh sach san pham: \n" << endl;
    for(int i = 0; i < n; i++){
        cout << "San pham " << i + 1 << ":" << endl;
        danhSach[i].hien();
        cout << endl;
    }

    float maxLuong = 0;
    for(int i = 0; i < n; i++){
        if(danhSach[i].tinhLuong() > maxLuong)
            maxLuong = danhSach[i].tinhLuong();
    }
    cout << "\n\nCac cong nhan co tong luong cao nhat: \n" << endl;
    for(int i = 0; i < n; i++){
        if(danhSach[i].tinhLuong() == maxLuong){
            cout << danhSach[i].tenCongNhan << endl;
        }
    }
    return 0;
}

    

# data[].attributes.attachment_link.readable_text
#include <iostream>

using namespace std;
class Parent
{
public:
  Parent() { cout << "ham tao lop cha" << endl; }
  ~Parent() { cout << "ham huy lop cha" << endl; }
};

class Child : public Parent
{
public:
  Child() { cout << "ham tao lop con" << endl; }
  ~Child() { cout << "ham huy lop con" << endl; }
};

void ham(Child c) {}
  int main() {
    Child obj1;
    ham(obj1);  
    return 0;
  }