Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Nov 9, 2023
2 parents d3541f2 + ca09a7c commit c06014f
Show file tree
Hide file tree
Showing 24 changed files with 1,418 additions and 38 deletions.
48 changes: 48 additions & 0 deletions 2. Bai132/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
#include <iostream>
using namespace std;

struct DiemKhongGian
{
float x;
float y;
float z;
};
typedef struct DiemKhongGian DIEMKHONGGIAN;

struct HinhCau
{
DIEMKHONGGIAN I;
float R;
};
typedef struct HinhCau HINHCAU;

void Nhap(DIEMKHONGGIAN&);
void Nhap(HINHCAU&);

float TheTich(HINHCAU);

int main()
{
HINHCAU s;
cout << "Nhap hinh cau: \n";
Nhap(s);

cout << "The Tich hinh cau vua nhap: " << TheTich(s);

return 0;
}

void Nhap(DIEMKHONGGIAN& P)
{
cout << "Nhap x: ";
cin >> P.x;
cout << "Nhap y: ";
cin >> P.y;
cout << "Nhap z: ";
cin >> P.z;
}

void Nhap(HINHCAU& c)
{
cout << "Nhap tam:\n";
Nhap(c.I);
cout << "Nhap ban kinh: ";
cin >> c.R;
}

float TheTich(HINHCAU c)
{
return float((float)4 / 3 * 3.14 * c.R * c.R * c.R);
}
63 changes: 62 additions & 1 deletion 2. Bai137/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,69 @@
#include <iostream>
#include <iomanip>
using namespace std;

struct Diem
{
float x;
float y;
};
typedef struct Diem DIEM;

struct TamGiac
{
DIEM A;
DIEM B;
DIEM C;
};
typedef struct TamGiac TAMGIAC;

void Nhap(DIEM&);
void Xuat(DIEM);

void Nhap(TAMGIAC&);
void Xuat(TAMGIAC);

int main()
{
TAMGIAC M;
Nhap(M);
cout << "\nTam giac vua nhap:";
Xuat(M);
return 1;
}

return 0;
void Nhap(DIEM& P)
{
cout << "Nhap x: ";
cin >> P.x;
cout << "Nhap y: ";
cin >> P.y;
}

void Xuat(DIEM P)
{
cout << setw(6);
cout << setprecision(3);
cout << "\nx: " << P.x;
cout << "\ny: " << P.y;
}

void Nhap(TAMGIAC& t)
{
cout << "Nhap diem A:\n";
Nhap(t.A);
cout << "Nhap diem B:\n";
Nhap(t.B);
cout << "Nhap diem C:\n";
Nhap(t.C);
}

void Xuat(TAMGIAC t)
{
cout << "\nToa do diem A: ";
Xuat(t.A);
cout << "\nToa do diem B: ";
Xuat(t.B);
cout << "\nToa do diem C: ";
Xuat(t.C);
}
60 changes: 59 additions & 1 deletion 2. Bai142/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,66 @@
#include <iostream>
using namespace std;

struct Diem
{
float x;
float y;
};
typedef struct Diem DIEM;

struct TamGiac
{
DIEM A;
DIEM B;
DIEM C;
};
typedef struct TamGiac TAMGIAC;

void Nhap(DIEM&);
void Nhap(TAMGIAC&);
void Xuat(DIEM);
DIEM HoanhLonNhat(TAMGIAC t);

int main()
{
TAMGIAC t;
Nhap(t);

cout << "\nDiem co Tung do lon nhat la:";
Xuat(HoanhLonNhat(t));
return 0;
}
}

void Nhap(DIEM& I)
{
cout << "\nNhap x: ";
cin >> I.x;
cout << "Nhap y: ";
cin >> I.y;
}

void Nhap(TAMGIAC& t)
{
cout << "\nNhap A: ";
Nhap(t.A);
cout << "\nNhap B: ";
Nhap(t.B);
cout << "\nNhap C: ";
Nhap(t.C);
}

void Xuat(DIEM I)
{
cout << "(" << I.x << ", " << I.y << ")";
}

DIEM HoanhLonNhat(TAMGIAC t)
{
DIEM lc = t.A;
if (t.B.x > lc.x)
lc = t.B;
if (t.C.x>lc.x)
lc = t.C;
return lc;
}

31 changes: 31 additions & 0 deletions 2. Bai147/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
#include <iostream>
using namespace std;

struct DuongThang
{
float a;
float b;
float c;
};
typedef struct DuongThang DUONGTHANG;

void Nhap(DUONGTHANG&);
void Xuat(DUONGTHANG);

int main()
{
DUONGTHANG d;
Nhap(d);
Xuat(d);

return 0;
}

void Nhap(DUONGTHANG& d)
{
cout << "\nNhap a: ";
cin >> d.a;
cout << "Nhap b: ";
cin >> d.b;
cout << "Nhap c: ";
cin >> d.c;
}

void Xuat(DUONGTHANG d)
{
cout << "\na: " << d.a;
cout << "\nb: " << d.b;
cout << "\nc: " << d.c;
}
42 changes: 42 additions & 0 deletions 2. Bai152/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,50 @@
#include <iostream>
using namespace std;

struct DuongThang
{
float a;
float b;
float c;
};
typedef struct DuongThang DUONGTHANG;

void Nhap(DUONGTHANG&);
int ktSongSong(DUONGTHANG, DUONGTHANG);

int main()
{
DUONGTHANG ln1;
cout << "Nhap duong thang thu nhat:\n";
Nhap(ln1);

DUONGTHANG ln2;
cout << "Nhap duong thang thu hai:\n";
Nhap(ln2);

if (ktSongSong(ln1, ln2))
cout << "Hai duong thang Song Song nhau";
else
cout << "Hai duong thang khong Song Song nhau";

return 0;
}

void Nhap(DUONGTHANG& l)
{
cout << "Nhap a: ";
cin >> l.a;
cout << "Nhap b: ";
cin >> l.b;
cout << "Nhap c: ";
cin >> l.c;
}

int ktSongSong(DUONGTHANG d1, DUONGTHANG d2)
{
float D = d1.a * d2.b - d2.a * d1.b;
float Dx = -d1.c * d2.b + d2.c * d1.b;
if (D == 0 && Dx != 0)
return 1;
return 0;
}
37 changes: 37 additions & 0 deletions 2. Bai157/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
#include <iostream>
#include <iomanip>

using namespace std;

struct DaThuc
{
int n;
float a[100];
};
typedef struct DaThuc DATHUC;
void Nhap(DATHUC&);
void Xuat(DATHUC);

int main()
{
DATHUC f;
Nhap(f);
cout << "\n Da thuc vua nhap la: ";
cout << endl;
Xuat(f);

return 0;
}

void Nhap(DATHUC& f)
{
cout << "Nhap n: ";
cin >> f.n;
for (int i = f.n; i >= 0; i--)
{
cout << "Nhap a[" << i << "]: ";
cin >> f.a[i];
}
}

void Xuat(DATHUC f)
{
for (int i = f.n; i >= 1; i--)
{
cout << setw(8) << "(" << f.a[i] << ")";
cout << "x^" << i << "+";
}
cout << setw(8) << "(" << f.a[0] << ")";
}
Loading

0 comments on commit c06014f

Please sign in to comment.