Alx09

Untitled

Apr 29th, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. using namespace std;
  6.  
  7. class legume{
  8. private:
  9. char nume[30], tara[30];
  10. float pret;
  11. public:
  12. void citire_leg(void);
  13. void afisare_leg(void);
  14. };
  15.  
  16. void legume::citire_leg(void)
  17. {
  18. cout<<"Introduceti informatiile legate de leguma: "<<endl;
  19. cout<<"Denumire: "; cin>> nume;
  20. cout<<"Tara de origine: "; cin>> tara;
  21. cout<<"Pret: "; cin>> pret;
  22. cout << endl;
  23.  
  24. }
  25.  
  26. void legume::afisare_leg(void){
  27. cout << nume <<", de origine din " << tara <<"."<<endl;
  28. cout << "Pret: "<<pret << " lei.\n\n";
  29. }
  30.  
  31. int main(){
  32. int i, n;
  33. legume leg[15];
  34. cout <<"Numar de legume: "; cin >> n;
  35. getchar();
  36. for(i = 0;i < n; i++)
  37. leg[i].citire_leg();
  38.  
  39. cout<<"In stoc se afla legumele: \n\n";
  40. for(i = 0;i < n; i++)
  41. leg[i].afisare_leg();
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment