#include<iostream>
#include<string>
using namespace std;
struct TaiNghe {
string MaTaiNghe;
string TenTaiNghe;
string NuocSX;
int DonGia;
int SoLuong;
int ThanhTien;
TaiNghe* pNext;
};
void Nhap(TaiNghe*& head) {
TaiNghe* p = nullptr;
int n;
cout << "Nhap so luong tai nghe: ";
cin >> n;
for (int i = 0; i < n; i++) {
TaiNghe* node = new TaiNghe();
cout << "Nhap ma tai nghe: ";
cin >> node->MaTaiNghe;
cout << "Nhap ten tai nghe: ";
cin >> node->TenTaiNghe;
cout << "Nhap nuoc san xuat: ";
cin >> node->NuocSX;
cout << "Nhap don gia: ";
cin >> node->DonGia;
cout << "Nhap so luong: ";
cin >> node->SoLuong;
node->ThanhTien = node->DonGia * node->SoLuong;
node->pNext = nullptr;
if (head == nullptr) {
head = node;
p = node;
}
else {
p->pNext = node;
p = node;
}
}
}
void Xuat(TaiNghe* head) {
if (head == nullptr) {
cout << "Danh sach rong!\n";
return;
}
TaiNghe* p = head;
while (p != nullptr) {
cout << "Ma tai nghe: " << p->MaTaiNghe << "\n";
cout << "Ten tai nghe: " << p->TenTaiNghe << "\n";
cout << "Nuoc san xuat: " << p->NuocSX << "\n";
cout << "Don gia: " << p->DonGia << "\n";
cout << "So luong: " << p->SoLuong << "\n";
cout << "Thanh tien: " << p->ThanhTien << "\n\n";
p = p->pNext;
}
}
void TimKiem(TaiNghe* head, string x) {
TaiNghe* p = head;
bool found = false;
while (p != nullptr) {
if (p->TenTaiNghe == x) {
cout << "Ma tai nghe: " << p->MaTaiNghe << "\n";
cout << "Ten tai nghe: " << p->TenTaiNghe << "\n";
cout << "Nuoc san xuat: " << p->NuocSX << "\n";
cout << "Don gia: " << p->DonGia << "\n";
cout << "So luong: " << p->SoLuong << "\n";
cout << "Thanh tien: " << p->ThanhTien << "\n\n";
found = true;
}
p = p->pNext;
}
if (!found) {
cout << "Khong tim thay tai nghe co ten " << x << "\n\n";
}
}
void SapXep(TaiNghe*& head) {
TaiNghe* i,