Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //NOTE
- #include <string>
- using namespace std;
- class Student{
- string nume;
- int an;
- int nota_poo;
- int nota_pc;
- public:
- Student(){
- nume="NULL";
- an=0;
- nota_poo=0;
- nota_pc=0;
- }
- void set(){
- cout<<"Numele: "<<endl;
- cin>>nume;
- cout<<"Anul de studiu: "<<endl;
- cin>>an;
- cout<<"Nota la POO: "<<endl;
- cin>>nota_poo;
- cout<<"Nota la PC: "<<endl;
- cin>>nota_pc;
- }
- int get_an(){
- return an;
- }
- int medie(){
- return nota_poo+nota_pc;
- }
- void afisare(){
- cout<<nume<<", anul"<<an<<", media"<<(nota_poo+nota_pc)/2<<endl;
- }
- };
- int main() {
- int nr;
- cout<<"Introduceti numarul de studenti: "<<endl;
- cin>>nr;
- Student *pob=new Student[nr];
- for(int k=0; k<nr; k++){
- pob[k].set();
- }
- for(int i=1; i<5; i++){
- int max=0;
- Student aux;
- for(int j=0; j<nr; j++){
- if(pob[j].get_an()==i){
- if(pob[j].medie()>=max){
- aux = pob[j];
- }
- }
- }
- aux.afisare();
- }
- return 0;
- }
- //MAGAZIN
- #include <iostream>
- #include <string>
- using namespace std;
- class Magazin{
- string denumire;
- string model;
- int pret;
- public:
- Magazin(){
- denumire="NULL";
- model="NULL";
- pret=0;
- }
- void set(){
- cout<<"Introduceti denumirea: "<<endl;
- cin>>denumire;
- cout<<"Introduceti modelul: "<<endl;
- cin>>model;
- cout<<"Introduceti pretul: "<<endl;
- cin>>pret;
- }
- int ghet_pret(){
- return pret;
- }
- void afisare(){
- cout<<denumire<<","<<model<<","<<pret<<endl;
- }
- };
- int main() {
- int nr, prag;
- cout<<"Introduceti numarul produselor: "<<endl;
- cin>>nr;
- Magazin *pob= new Magazin[nr];
- for(int i=0; i<nr; i++){
- pob[i].set();
- }
- for (int j=0; j<nr-1; j++){
- for (int k=j+1; k<nr;k++){
- if (pob[j].ghet_pret() > pob[k].ghet_pret())
- {
- Magazin aux = pob[j];
- pob[j] = pob[k];
- pob[k] = aux;
- }
- }
- }
- cout<<"Introduceti pretul maxim: "<<endl;
- cin>>prag;
- for (int l=0; l<nr; l++){
- if (pob[l].ghet_pret() < prag){
- pob[l].afisare();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment