Advertisement
Guest User

da

a guest
Jan 28th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. ifstream in("francesca.in");
  9.  
  10. struct tampit{
  11.  
  12. char nume[30], pre[30];
  13. int nr_note, medie;
  14. char corigent[9];
  15.  
  16. }x[30];
  17.  
  18. int main()
  19. {
  20. int nota, i=0;
  21. while(!in.eof())
  22. {
  23. in >> x[i].nume >> x[i].pre;
  24. strcat(x[i].nume, " ");
  25. strcat(x[i].nume, x[i].pre);
  26. x[i].nume[strlen(x[i].nume)-1]=0;
  27. char c=0;
  28. while(c!='\n')
  29. {
  30. in >> nota >> c;
  31. x[i].medie+=nota;
  32. x[i].nr_note++;
  33. }
  34. x[i].medie/=x[i].nr_note;
  35. i++;
  36. if(x[i].medie<5)
  37. strcpy(x[i].corigent, "Corigent");
  38. else
  39. strcpy(x[i].corigent, "Promovat");
  40. }
  41. int n=i;
  42. for(int i=0; i<n-1; i++)
  43. {
  44. for(int j=i+1; j<n; j++)
  45. {
  46. if(x[i].medie<x[j].medie)
  47. {
  48. swap(x[i], x[j]);
  49. }
  50. }
  51. }
  52. printf("+----------------------+-------+----------+\n");
  53. printf("| NUMELE Si Prenumele | Medie | Situatie |\n");
  54. printf("+----------------------+-------+----------+\n");
  55. for(int i=0; i<n; i++)
  56. {
  57. printf("| %-20s | %2d | %s |\n", x[i].nume, x[i].medie, x[i].corigent);
  58. }
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement