Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. struct date
  7. {
  8. char nume[256], prenume[256];
  9. float media, teza;
  10. };
  11.  
  12. int main()
  13. {
  14. int n;
  15. cout<<"n=";
  16. cin>>n;
  17. cin.get();
  18. date v[100], aux;
  19.  
  20.  
  21. for(int i=0; i<n; i++)
  22. {
  23. cout<<"Nume: ";
  24. cin.get(v[i].nume, 255);
  25. cin.get();
  26. cout<<"Prenume: ";
  27. cin.get(v[i].prenume, 255);
  28. cin.get();
  29. cout<<"media: ";
  30. cin>>v[i].media;
  31. cin.get();
  32. cout<<"teza: ";
  33. cin>>v[i].teza;
  34. cin.get();
  35. cout<<endl;
  36. }
  37.  
  38. for(int i=0; i<n-1; i++)
  39. for(int j=i; j<n; j++)
  40. if(strcmp(v[i].nume, v[j].nume)==1 ||
  41. strcmp(v[i].nume, v[j].nume)==0 &&
  42. strcmp(v[i].prenume, v[j].prenume)==1
  43. )
  44. {
  45. aux=v[i];
  46. v[i]=v[j];
  47. v[j]=aux;
  48. }
  49. for(int i=0; i<n; i++)
  50. if((v[i].media*3+v[i].teza)/4<5)
  51. cout<<v[i].nume <<" "<<v[i].prenume<<endl;
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement