Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- using namespace std;
- typedef struct
- {
- char Ten[30];
- int sdt;
- } danhba;
- int nhap(int &n)
- {
- cout<<"nhap SL DB: ";
- cin>>n;
- return 0;
- }
- int nhapluachon(int &chon)
- {
- cout<<"\nnhap lua chon: ";
- cin>>chon;
- return chon;
- }
- void menu(void)
- {
- cout<<"\n==============MENU=============\n";
- cout<<"\n1.xem danh sach";
- cout<<"\n2.them danh sach";
- cout<<"\n0.thoat";
- }
- void nhapds(danhba ds[50], int n)
- {
- for(int i = 0;i < n;i++)
- {
- cout<<"\nnhap ten: ";
- fflush(stdin);
- gets(ds[i].Ten);
- cout<<"nhap sdt: ";
- cin>>ds[i].sdt;
- }
- }
- void themdb(danhba ds[], int n, int &m)
- {
- cout<<"\nnhap SL DB ban muon them: ";
- cin>>m;
- for(int i = n;i < n + m;i++)
- {
- cout<<"nhap ten: ";
- fflush(stdin);
- gets(ds[i].Ten);
- cout<<"nhap sdt: ";
- cin>>ds[i].sdt;
- }
- }
- void xuatds(danhba ds[], int n, int m)
- {
- for(int i = 0;i < n + m;i++)
- {
- cout<<"\nten: "<<ds[i].Ten;
- cout<<"\nsdt: "<<ds[i].sdt;
- }
- }
- int main()
- {
- danhba ds[50];
- int n,m,chon;
- nhap(n);
- nhapds(ds,n);
- do
- {
- menu();
- nhapluachon(chon);
- switch(chon)
- {
- case 1:
- {
- xuatds(ds,n,m);
- } break;
- case 2:
- {
- themdb(ds,n,m);
- } break;
- }
- }
- while(chon != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement