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.
- Loading branch information
1 parent
dea4ccd
commit f1a9988
Showing
9 changed files
with
502 additions
and
6 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,65 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
using namespace std; | ||
|
||
struct DaThuc | ||
{ | ||
float a[100]; | ||
int n; | ||
}; | ||
typedef struct DaThuc DATHUC; | ||
|
||
void Nhap(DATHUC&); | ||
void Xuat(DATHUC); | ||
|
||
DATHUC Tich(DATHUC, DATHUC); | ||
|
||
int main() | ||
{ | ||
DATHUC f1; | ||
cout << "Nhap da thuc f1:" << endl; | ||
Nhap(f1); | ||
|
||
DATHUC f2; | ||
cout << "Nhap da thuc f2:" << endl; | ||
Nhap(f2); | ||
|
||
cout << "Tich da thuc: f1 * f2:" << endl; | ||
Xuat(Tich(f1, f2)); | ||
|
||
return 0; | ||
} | ||
|
||
void Nhap(DATHUC& f) | ||
{ | ||
cout << "Nhap bac da thuc: "; | ||
cin >> f.n; | ||
for (int i = f.n; i >= 0; i--) | ||
{ | ||
cout << "Nhap he so a[" << i << "]: "; | ||
cin >> f.a[i]; | ||
} | ||
} | ||
|
||
void Xuat(DATHUC f) | ||
{ | ||
for (int i = f.n; i >= 1; i--) | ||
{ | ||
cout << f.a[i]; | ||
cout << "x^" << i; | ||
cout << setw(3); | ||
} | ||
cout << f.a[0]; | ||
} | ||
|
||
DATHUC Tich(DATHUC f, DATHUC g) | ||
{ | ||
DATHUC temp; | ||
temp.n = f.n + g.n; | ||
for (int i = temp.n; i >= 0; i--) | ||
temp.a[i] = 0; | ||
for (int i = 0; i <= g.n; i++) | ||
for (int j = 0; j <= f.n; j++) | ||
temp.a[i + j] += g.a[i] * f.a[j]; | ||
return temp; | ||
} |
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,49 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
using namespace std; | ||
|
||
struct DaThuc | ||
{ | ||
float a[100]; | ||
int n; | ||
}; | ||
typedef struct DaThuc DATHUC; | ||
|
||
void Nhap(DATHUC&); | ||
float VT(DATHUC, float); | ||
|
||
int main() | ||
{ | ||
DATHUC f1; | ||
cout << "Nhap da thuc f1:" << endl; | ||
Nhap(f1); | ||
|
||
float x; | ||
cout << "Nhap so thuc x:" << endl; | ||
cin >> x; | ||
|
||
cout << "x= "<<x<<" co gia tri la : " << VT(f1,x); | ||
|
||
return 0; | ||
} | ||
|
||
void Nhap(DATHUC& f) | ||
{ | ||
cout << "Nhap bac da thuc: "; | ||
cin >> f.n; | ||
for (int i = f.n; i >= 0; i--) | ||
{ | ||
cout << "Nhap he so a[" << i << "]: "; | ||
cin >> f.a[i]; | ||
} | ||
} | ||
|
||
float VT(DATHUC f, float x) | ||
{ | ||
float s=0.0; | ||
for (int i = 1; i <= f.n; i++) | ||
f.a[i] = f.a[i] * pow(x, i); | ||
for (int i = 0; i <= f.n; i++) | ||
s += f.a[i]; | ||
return s; | ||
} |
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,70 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
struct diem | ||
{ | ||
float x; | ||
float y; | ||
}; | ||
typedef struct diem DIEM; | ||
|
||
void Nhap(DIEM&); | ||
void Nhap(DIEM[], int&); | ||
void Xuat(DIEM); | ||
float KhoangCachGoc(DIEM); | ||
DIEM GanGocNhat(DIEM[], int); | ||
|
||
|
||
int main() | ||
{ | ||
DIEM a[100]; | ||
int n; | ||
Nhap(a, n); | ||
|
||
cout << "Diem gan goc toa do nhat la:"; | ||
Xuat(GanGocNhat(a, n)); | ||
|
||
return 0; | ||
} | ||
} | ||
|
||
void Nhap(DIEM& P) | ||
{ | ||
cout << "Nhap x: "; | ||
cin >> P.x; | ||
cout << "Nhap y: "; | ||
cin >> P.y; | ||
} | ||
|
||
void Nhap(DIEM P[], int& n) | ||
{ | ||
cout << "Nhap so luong diem: "; | ||
cin >> n; | ||
for (int i = 0; i <= n - 1; i++) | ||
{ | ||
cout << "Nhap diem thu " << i << ": " << endl; | ||
Nhap(P[i]); | ||
} | ||
} | ||
|
||
void Xuat(DIEM P) | ||
{ | ||
cout << "\nx: " << P.x; | ||
cout << "\ny: " << P.y; | ||
} | ||
|
||
|
||
|
||
float KhoangCachGoc(DIEM P) | ||
{ | ||
return sqrt(P.x * P.x + P.y * P.y); | ||
} | ||
|
||
DIEM GanGocNhat(DIEM a[], int n) | ||
{ | ||
DIEM lc = a[0]; | ||
for (int i = 0; i <= n - 1; i++) | ||
if (KhoangCachGoc(a[i]) < | ||
KhoangCachGoc(lc)) | ||
lc = a[i]; | ||
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,58 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
struct PhanSo | ||
{ | ||
int Tu; | ||
int Mau; | ||
}; | ||
typedef struct PhanSo PHANSO; | ||
|
||
void Nhap(PHANSO&); | ||
void Xuat(PHANSO); | ||
|
||
void Nhap(PHANSO[], int&); | ||
void Xuat(PHANSO[], int); | ||
|
||
int main() | ||
{ | ||
PHANSO P[100]; | ||
int n; | ||
Nhap(P, n); | ||
Xuat(P, n); | ||
return 0; | ||
} | ||
|
||
void Nhap(PHANSO& P) | ||
{ | ||
cout << "\nNhap Tu: "; | ||
cin >> P.Tu; | ||
cout << "Nhap Mau: "; | ||
cin >> P.Mau; | ||
} | ||
|
||
void Xuat(PHANSO P) | ||
{ | ||
cout << "\nTu: " << P.Tu; | ||
cout << "\nMau: " << P.Mau; | ||
} | ||
|
||
void Nhap(PHANSO a[], int& n) | ||
{ | ||
cout << "Nhap so luong phan so: "; | ||
cin >> n; | ||
for (int i = 0; i < n; i++) | ||
{ | ||
cout << "\nNhap a[" << i << "] = "; | ||
Nhap(a[i]); | ||
} | ||
} | ||
|
||
void Xuat(PHANSO a[], int n) | ||
{ | ||
for (int i = 0; i < n; i++) | ||
{ | ||
cout << "\na[" << i << "] = "; | ||
Xuat(a[i]); | ||
} | ||
} |
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,63 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
struct PhanSo | ||
{ | ||
int Tu; | ||
int Mau; | ||
}; | ||
typedef struct PhanSo PHANSO; | ||
|
||
void Nhap(PHANSO&); | ||
void Xuat(PHANSO); | ||
|
||
void Nhap(PHANSO[], int&); | ||
|
||
PHANSO DuongDau(PHANSO[], int); | ||
|
||
int main() | ||
{ | ||
PHANSO P[100]; | ||
int n; | ||
Nhap(P, n); | ||
cout << "Duong dau tien trong mang la: "; | ||
Xuat(DuongDau(P,n)); | ||
return 0; | ||
} | ||
} | ||
|
||
void Nhap(PHANSO& P) | ||
{ | ||
cout << "\nNhap Tu: "; | ||
cin >> P.Tu; | ||
cout << "Nhap Mau: "; | ||
cin >> P.Mau; | ||
} | ||
|
||
void Xuat(PHANSO P) | ||
{ | ||
cout << "\nTu: " << P.Tu; | ||
cout << "\nMau: " << P.Mau; | ||
} | ||
|
||
void Nhap(PHANSO a[], int& n) | ||
{ | ||
cout << "Nhap so luong phan so: "; | ||
cin >> n; | ||
for (int i = 0; i < n; i++) | ||
{ | ||
cout << "\nNhap a[" << i << "] = "; | ||
Nhap(a[i]); | ||
} | ||
} | ||
|
||
PHANSO DuongDau(PHANSO a[], int n) | ||
{ | ||
for (int i = 0; i < n; i++) | ||
{ | ||
if (a[i].Tu * a[i].Mau > 0) | ||
return a[i]; | ||
} | ||
PHANSO temp{ 0,1 }; | ||
return temp; | ||
} | ||
|
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,42 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
struct SoPhuc | ||
{ | ||
float Thuc; | ||
float Ao; | ||
}; | ||
typedef struct SoPhuc SOPHUC; | ||
|
||
void Nhap(SOPHUC&); | ||
void Nhap(SOPHUC[], int&); | ||
|
||
int main() | ||
{ | ||
SOPHUC a[100]; | ||
int n; | ||
Nhap(a, n); | ||
|
||
cout << "Da hoan thanh nhap mang mot chieu cac so phuc"; | ||
|
||
return 0; | ||
} | ||
|
||
void Nhap(SOPHUC& x) | ||
{ | ||
cout << "Nhap thuc: "; | ||
cin >> x.Thuc; | ||
cout << "Nhap ao: "; | ||
cin >> x.Ao; | ||
} | ||
|
||
void Nhap(SOPHUC a[], int& n) | ||
{ | ||
cout << "Nhap n: "; | ||
cin >> n; | ||
for (int i = 0; i < n; i++) | ||
{ | ||
cout << "Nhap a[" << i << "]: "; | ||
Nhap(a[i]); | ||
} | ||
} |
Oops, something went wrong.