Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. struct elev //structura se numeste elev
  6. {
  7. char nume[10];
  8. prenume[20];
  9. int nota;
  10. } a[20], c;
  11.  
  12. int main()
  13. {
  14. int n, i, j, S;
  15. cout<<"nr. de elevi: ";
  16. cin>>n;
  17. cout<<"Datele despre elev:"<<endl;
  18. for(i=1;i<=n;i++)
  19. {
  20. cout<<"Elevul "<<i<<": "<<endl;
  21. cout<<"Nume:";cin>>a[i].nume;
  22. cout<<"prenume:";cin>>a[i].prenume;
  23. cout<<"Nota:";cin>>a[i].nota;
  24. S=S+a[i].nota;
  25. }
  26. for(i=1;i<n;i++)
  27. for(j=i+1;j<=n;j++)
  28. if(a[i].nota<a[j].nota)
  29. {
  30. c=a[i]; //VARIABILA C ESTE DE TIP STRUCT
  31. a[i]=a[j];
  32. a[j]=c;
  33. }
  34. cout<<"afisarea elevilor promovati:"<<endl;
  35. for(i=1;i<=n;i++)
  36. if(a[i].nota>=5) cout<<a[i].nume<<" "<<a[i].prenume<<" "<<a[i].nota<<" "<<endl;
  37. cout<<"media notelor="<<S*1.0/n<<endl;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement