Quanlithuviensach
Chia sẻ bởi Đặng Thanh Công |
Ngày 26/04/2019 |
38
Chia sẻ tài liệu: quanlithuviensach thuộc Tin học 12
Nội dung tài liệu:
#include
#include
#include
#include
#include
#include
#include
#include
class sach
{
public:
char tensach[30],theloai[30];
char masach[10],tentg[30],nhaxuatban[30];
void nhapsach();
void insach();
int sosach;
};
class ds_sach :public sach
{
public:
sach *S;
void nhapds_sach();
void timsach(char ten[30]);
void xoasach(char ten[30]);
void themsach(sach x);
void inds_sach();
void thongketheloai();
void docsach();
void ghisach();
};
int i,j,chon;
void sach::nhapsach()
{
cin.ignore();
cout<<"nhap ma sach: ";
cin.getline(masach,10);
cout<<"nhap ten sach: ";
cin.getline(tensach,30);
cout<<"nhap the loai: ";
cin.getline(theloai,30);
cout<<"nhap ten tac gia: ";
cin.getline(tentg,30);
cout<<"nhap nha xuat ban: ";
cin.getline(tensach,30);
}
void sach::insach()
{
cout<<"=========================================================="< cout<<"thong tin sach"< cout< cout<}
void ds_sach::nhapds_sach()
{
cout<<"nhap so luong sach: ";
cin>>sosach;
S=new sach[sosach+1];
for(int i=1;i<=sosach;i++)
S[i].nhapsach();
}
void ds_sach::timsach(char ten[30])
{
int i=1;
while(i<=sosach && strcmp(S[i].tensach,ten)!=0)
i++;
if(i>sosach)
cout<<"khong so sach nay"< else
{
cout<<"da tim thay-in thong tin sach"< S[i].insach();
}
}
void ds_sach::themsach(sach x)
{
sosach++;
S[sosach]=x;
}
void ds_sach::xoasach(char ten[30])
{
int i=1;
while(i<=sosach && strcmp(S[i].tensach,ten)!=0)
i++;
if(i>sosach)
cout<<"khong thay sach nay"< else
{
cout<<"da tim thay-thuc hien xoa"< sosach--;
for(int j=i;j<=sosach;j++)
S[j]=S[j+1];
}
}
void ds_sach::inds_sach()
{
cout<<"in danh sach sach"< for(int i=1;i<=sosach;i++)
S[i].insach();
}
void ds_sach::thongketheloai()
{
char theloai[30];
int dem=0;
cin.ignore();
cout<<"nhap ten the loai: ";
cin.getline(theloai,30);
for(int i=1;i<=sosach;i++)
for(int j=i;j<=sosach+1;j++)
{
if(S[i].theloai==S[j].theloai)
dem++;
cout<<"so sach trong the loai: "< cout< }
}
void ds_sach::ghisach()
{
char taptin[30];
strcpy(taptin,"DS_sach.txt");
ofstream f(taptin,ios::app);
if(f.bad()!=0)
{
cout<<"
#include
#include
#include
#include
#include
#include
#include
class sach
{
public:
char tensach[30],theloai[30];
char masach[10],tentg[30],nhaxuatban[30];
void nhapsach();
void insach();
int sosach;
};
class ds_sach :public sach
{
public:
sach *S;
void nhapds_sach();
void timsach(char ten[30]);
void xoasach(char ten[30]);
void themsach(sach x);
void inds_sach();
void thongketheloai();
void docsach();
void ghisach();
};
int i,j,chon;
void sach::nhapsach()
{
cin.ignore();
cout<<"nhap ma sach: ";
cin.getline(masach,10);
cout<<"nhap ten sach: ";
cin.getline(tensach,30);
cout<<"nhap the loai: ";
cin.getline(theloai,30);
cout<<"nhap ten tac gia: ";
cin.getline(tentg,30);
cout<<"nhap nha xuat ban: ";
cin.getline(tensach,30);
}
void sach::insach()
{
cout<<"=========================================================="<
void ds_sach::nhapds_sach()
{
cout<<"nhap so luong sach: ";
cin>>sosach;
S=new sach[sosach+1];
for(int i=1;i<=sosach;i++)
S[i].nhapsach();
}
void ds_sach::timsach(char ten[30])
{
int i=1;
while(i<=sosach && strcmp(S[i].tensach,ten)!=0)
i++;
if(i>sosach)
cout<<"khong so sach nay"<
{
cout<<"da tim thay-in thong tin sach"<
}
}
void ds_sach::themsach(sach x)
{
sosach++;
S[sosach]=x;
}
void ds_sach::xoasach(char ten[30])
{
int i=1;
while(i<=sosach && strcmp(S[i].tensach,ten)!=0)
i++;
if(i>sosach)
cout<<"khong thay sach nay"<
{
cout<<"da tim thay-thuc hien xoa"<
for(int j=i;j<=sosach;j++)
S[j]=S[j+1];
}
}
void ds_sach::inds_sach()
{
cout<<"in danh sach sach"<
S[i].insach();
}
void ds_sach::thongketheloai()
{
char theloai[30];
int dem=0;
cin.ignore();
cout<<"nhap ten the loai: ";
cin.getline(theloai,30);
for(int i=1;i<=sosach;i++)
for(int j=i;j<=sosach+1;j++)
{
if(S[i].theloai==S[j].theloai)
dem++;
cout<<"so sach trong the loai: "<
}
void ds_sach::ghisach()
{
char taptin[30];
strcpy(taptin,"DS_sach.txt");
ofstream f(taptin,ios::app);
if(f.bad()!=0)
{
cout<<"
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...
Người chia sẻ: Đặng Thanh Công
Dung lượng: |
Lượt tài: 2
Loại file:
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)