Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #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 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment