This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/NMLT-NTTMK-K18/5-258-struct
- Loading branch information
Showing
24 changed files
with
1,418 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] << ")"; | ||
} |
Oops, something went wrong.