Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4.  
  5. typedef struct
  6. {
  7. char Ten[30];
  8. int sdt;
  9. } danhba;
  10.  
  11. int nhap(int &n)
  12. {
  13. cout<<"nhap SL DB: ";
  14. cin>>n;
  15.  
  16. return 0;
  17. }
  18.  
  19. int nhapluachon(int &chon)
  20. {
  21. cout<<"\nnhap lua chon: ";
  22. cin>>chon;
  23.  
  24. return chon;
  25. }
  26.  
  27. void menu(void)
  28. {
  29. cout<<"\n==============MENU=============\n";
  30. cout<<"\n1.xem danh sach";
  31. cout<<"\n2.them danh sach";
  32. cout<<"\n0.thoat";
  33. }
  34.  
  35. void nhapds(danhba ds[50], int n)
  36. {
  37. for(int i = 0;i < n;i++)
  38. {
  39. cout<<"\nnhap ten: ";
  40. fflush(stdin);
  41. gets(ds[i].Ten);
  42. cout<<"nhap sdt: ";
  43. cin>>ds[i].sdt;
  44. }
  45. }
  46.  
  47. void themdb(danhba ds[], int n, int &m)
  48. {
  49. cout<<"\nnhap SL DB ban muon them: ";
  50. cin>>m;
  51.  
  52. for(int i = n;i < n + m;i++)
  53. {
  54. cout<<"nhap ten: ";
  55. fflush(stdin);
  56. gets(ds[i].Ten);
  57. cout<<"nhap sdt: ";
  58. cin>>ds[i].sdt;
  59. }
  60. }
  61.  
  62. void xuatds(danhba ds[], int n, int m)
  63. {
  64. for(int i = 0;i < n + m;i++)
  65. {
  66. cout<<"\nten: "<<ds[i].Ten;
  67. cout<<"\nsdt: "<<ds[i].sdt;
  68. }
  69. }
  70.  
  71.  
  72. int main()
  73. {
  74. danhba ds[50];
  75. int n,m,chon;
  76.  
  77. nhap(n);
  78. nhapds(ds,n);
  79.  
  80. do
  81. {
  82. menu();
  83. nhapluachon(chon);
  84.  
  85. switch(chon)
  86. {
  87. case 1:
  88. {
  89. xuatds(ds,n,m);
  90. } break;
  91.  
  92. case 2:
  93. {
  94. themdb(ds,n,m);
  95. } break;
  96. }
  97. }
  98. while(chon != 0);
  99.  
  100. return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement