DDSSEE

Untitled

Jan 9th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <iostream> //NOTE
  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.  
  64. class Magazin{
  65. string denumire;
  66. string model;
  67. int pret;
  68. public:
  69. Magazin(){
  70. denumire="NULL";
  71. model="NULL";
  72. pret=0;
  73. }
  74. void set(){
  75. cout<<"Introduceti denumirea: "<<endl;
  76. cin>>denumire;
  77. cout<<"Introduceti modelul: "<<endl;
  78. cin>>model;
  79. cout<<"Introduceti pretul: "<<endl;
  80. cin>>pret;
  81. }
  82. int ghet_pret(){
  83. return pret;
  84. }
  85. void afisare(){
  86. cout<<denumire<<","<<model<<","<<pret<<endl;
  87. }
  88.  
  89. };
  90. int main() {
  91. int nr, prag;
  92. cout<<"Introduceti numarul produselor: "<<endl;
  93. cin>>nr;
  94. Magazin *pob= new Magazin[nr];
  95. for(int i=0; i<nr; i++){
  96. pob[i].set();
  97. }
  98. for (int j=0; j<nr-1; j++){
  99. for (int k=j+1; k<nr;k++){
  100. if (pob[j].ghet_pret() > pob[k].ghet_pret())
  101. {
  102. Magazin aux = pob[j];
  103. pob[j] = pob[k];
  104. pob[k] = aux;
  105. }
  106. }
  107. }
  108. cout<<"Introduceti pretul maxim: "<<endl;
  109. cin>>prag;
  110. for (int l=0; l<nr; l++){
  111. if (pob[l].ghet_pret() < prag){
  112. pob[l].afisare();
  113. }
  114. }
  115. return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment