Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<string.h>
- using namespace std;
- class legume{
- private:
- char nume[30], tara[30];
- float pret;
- public:
- void citire_leg(void);
- void afisare_leg(void);
- };
- void legume::citire_leg(void)
- {
- cout<<"Introduceti informatiile legate de leguma: "<<endl;
- cout<<"Denumire: "; cin>> nume;
- cout<<"Tara de origine: "; cin>> tara;
- cout<<"Pret: "; cin>> pret;
- cout << endl;
- }
- void legume::afisare_leg(void){
- cout << nume <<", de origine din " << tara <<"."<<endl;
- cout << "Pret: "<<pret << " lei.\n\n";
- }
- int main(){
- int i, n;
- legume leg[15];
- cout <<"Numar de legume: "; cin >> n;
- getchar();
- for(i = 0;i < n; i++)
- leg[i].citire_leg();
- cout<<"In stoc se afla legumele: \n\n";
- for(i = 0;i < n; i++)
- leg[i].afisare_leg();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment