DDSSEE

Untitled

Jan 9th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class Student{
  5.     string nume;
  6.     int an;
  7.     int nota_poo;
  8.     int nota_pc;
  9.     public:
  10.         Student(){
  11.             nume="NULL";
  12.             an=0;
  13.             nota_poo=0;
  14.             nota_pc=0;
  15.         }
  16.         void set(){
  17.             cout<<"Numele: "<<endl;
  18.             cin>>nume;
  19.             cout<<"Anul de studiu: "<<endl;
  20.             cin>>an;
  21.             cout<<"Nota la POO: "<<endl;
  22.             cin>>nota_poo;
  23.             cout<<"Nota la PC: "<<endl;
  24.             cin>>nota_pc;
  25.         }
  26.         int get_an(){
  27.             return an;
  28.         }
  29.         int medie(){
  30.             return nota_poo+nota_pc;
  31.         }
  32.         void afisare(){
  33.             cout<<nume<<", anul"<<an<<", media"<<(nota_poo+nota_pc)/2<<endl;
  34.         }
  35. };
  36. int main() {
  37.     int nr;
  38.     cout<<"Introduceti numarul de studenti: "<<endl;
  39.     cin>>nr;
  40.     Student *pob=new Student[nr];
  41.     for(int k=0; k<nr; k++){
  42.         pob[k].set();
  43.     }
  44.     for(int i=1; i<5; i++){
  45.         int max=0;
  46.         Student aux;
  47.         for(int j=0; j<nr; j++){
  48.             if(pob[j].get_an()==i){
  49.                 if(pob[j].medie()>=max){
  50.                     aux = pob[j];
  51.                 }
  52.             }
  53.         }
  54.         aux.afisare();
  55.     }
  56.     return 0;
  57. }
  58.  
  59. //magazin
  60. #include <iostream>
  61. #include <string>
  62. using namespace std;
  63. class Student{
  64.     string nume;
  65.     int an;
  66.     int nota_poo;
  67.     int nota_pc;
  68.     public:
  69.         Student(){
  70.             nume="NULL";
  71.             an=0;
  72.             nota_poo=0;
  73.             nota_pc=0;
  74.         }
  75.         void set(){
  76.             cout<<"Numele: "<<endl;
  77.             cin>>nume;
  78.             cout<<"Anul de studiu: "<<endl;
  79.             cin>>an;
  80.             cout<<"Nota la POO: "<<endl;
  81.             cin>>nota_poo;
  82.             cout<<"Nota la PC: "<<endl;
  83.             cin>>nota_pc;
  84.         }
  85.         int get_an(){
  86.             return an;
  87.         }
  88.         int medie(){
  89.             return nota_poo+nota_pc;
  90.         }
  91.         void afisare(){
  92.             cout<<nume<<", anul"<<an<<", media"<<(nota_poo+nota_pc)/2<<endl;
  93.         }
  94. };
  95. int main() {
  96.     int nr;
  97.     cout<<"Introduceti numarul de studenti: "<<endl;
  98.     cin>>nr;
  99.     Student *pob=new Student[nr];
  100.     for(int k=0; k<nr; k++){
  101.         pob[k].set();
  102.     }
  103.     for(int i=1; i<5; i++){
  104.         int max=0;
  105.         Student aux;
  106.         for(int j=0; j<nr; j++){
  107.             if(pob[j].get_an()==i){
  108.                 if(pob[j].medie()>=max){
  109.                     aux = pob[j];
  110.                 }
  111.             }
  112.         }
  113.         aux.afisare();
  114.     }
  115.     return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment