#include using namespace std; #include #include #include #define MAX 100 typedef struct COMPUTER { int ID; char brand[50]; char model[30]; char CPU[10]; int RAM; }; typedef struct NODE { COMPUTER Info; NODE *pNext; //dia chi cua ban ke tiep }; typedef struct LIST { NODE *pHead; //nguoi dau tien }; void Initialize(LIST &list) { list.pHead = NULL; } bool isEmpty(LIST list) { return list.pHead == NULL; } NODE* CreateNode(COMPUTER x) { NODE *p = new NODE; //cap phat vung nho if(p != NULL) { p->Info = x; p->pNext = NULL; } return p; } void InsertHead(LIST &list, COMPUTER x) { NODE *p = CreateNode(x); if(p!=NULL) //tao duoc NODE { p->pNext = list.pHead; list.pHead = p; } } void Input1Computer(COMPUTER &c) { cout << "Input ID: " ; cin>>c.ID; cout << "Input brand: "; cin>>c.brand; cout<<"Input model: "; cin>> c.model; cout<<"Input CPU: "; cin>>c.CPU; cout<<"Input RAM: "; cin>>c.RAM; } void CreateList(LIST &list) { COMPUTER x; char tt; do { Input1Computer(x); InsertHead(list, x); //them x vao dau danh sach cout<<"Nhan 'y'|'Y' de tiep thuc them mot may tinh"<pNext) OutputComputer(p->Info); cout<pNext) { if(p->Info.brand == BRAND) { OutputComputer(p->Info); return; } } cout<<"KHONG TIM THAY MAY TINH CO HANG SX LA: "<pNext) fwrite(&p->Info, sizeof(COMPUTER), 1, f); fclose(f); } void docFile(LIST &list) { COMPUTER x; FILE *f = fopen("Computer.txt", "rb"); if(f == NULL) { cout<<"Loi mo file"<>brand; FindComputerBrand(list,brand); cout<<"Press y/Y to continue to find the brand"<