Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. struct eksponat{
  4. char name[30];
  5. int day;
  6. int price;
  7. };
  8. class Museum{
  9. public:
  10. int n;
  11. eksponat *mas;
  12. Museum(eksponat *a,int size)
  13. {
  14. mas=a;
  15. n=size;
  16. }
  17. void Print()
  18. {
  19. int i;
  20. for (i=0;i<n;i++)
  21. {
  22. cout<<"Name: "<<mas[i].name<<endl;
  23. cout<<"Kol-vo day: "<<mas[i].day<<endl;
  24. cout<<"Stoimost: "<<mas[i].price<<endl<<endl;
  25.  
  26. }
  27. }
  28. void Pay(){
  29. int i,k=0;
  30. for (i=0;i<n;i++)
  31. {
  32. k+=mas[i].day*mas[i].price;
  33. }
  34. cout<<"Stoimost ekspozicii:"<<k<<endl;
  35.  
  36. }
  37. ~Museum()
  38. {
  39. delete[] mas;
  40. };
  41. };
  42.  
  43. int main() {
  44. eksponat *c;
  45. Museum *A;
  46. int klv;
  47. cout<<"Kolvo eksponatov:"<<endl;
  48. cin>>klv;
  49. c=new eksponat[klv];
  50. for (int i=0;i<klv;i++)
  51. {
  52. cout<<"Name: "<<endl;
  53. cin>>c[i].name;
  54. cout<<"Kol-vo day: "<<endl;
  55. cin>>c[i].day;
  56. cout<<"Stoimost: "<<endl;
  57. cin>>c[i].price;
  58. }
  59. A=new Museum(c,klv);
  60. A->Print();
  61. A->Pay();
  62. delete A;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement