Advertisement
mercMatvey4

Untitled

Feb 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <windows.h>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. struct Students
  9. {
  10. string Name;
  11. float at;
  12. float sr;
  13. int ses[4];
  14. };
  15.  
  16. int main()
  17. {
  18. float sum = 0;
  19. SetConsoleOutputCP(1251);
  20. SetConsoleCP(1251);
  21. setlocale(LC_ALL,"");
  22. Students gr[5];
  23. // for (int i = 0; i < 5; i++)
  24. // {
  25. // cout << "Имя : ";
  26. // cin >> gr[i].Name;
  27. // cout << "Средний бал за аттестат : ";
  28. // cin >> gr[i].at;
  29. // cout << "Оценки за последнюю сессию : ";
  30. // for (int j = 0; j < 4; j++)
  31. // cin >> gr[i].ses[j];
  32. // cout << endl;
  33. // }
  34. ifstream fin("Students.txt");
  35. for(int i = 0; i < 5; ++i)
  36. {
  37. fin >> gr[i].Name;
  38. fin >> gr[i].at;
  39. for (int j = 0; j < 4; j++)
  40. fin >> gr[i].ses[j];
  41. }
  42. for (int i = 0; i < 5; i++)
  43. {
  44. for (int j = 0; j < 4; j++)
  45. {
  46. sum += gr[i].ses[j];
  47. }
  48. gr[i].sr = sum / 4;
  49. sum = 0;
  50. }
  51. cout << "Студенты, у которых средний балл по итогам сессии ниже среднего балла аттестата\n";
  52. for (int i = 0; i < 5; i++)
  53. {
  54. if (gr[i].sr < gr[i].at) cout << "Имя: " << gr[i].Name << "\n" << "Средний бал аттестата : " << gr[i].at << "\n" << "Средняя оценка за экзамен : " << gr[i].sr << "\n";
  55. cout << endl;
  56. }
  57. return 0;
  58. }
  59.  
  60. /*
  61. Матвей
  62. 4.7
  63. 4 5 5 4
  64. Кристина
  65. 4.8
  66. 5 5 5 5
  67. Игорь
  68. 3.8
  69. 4 4 4 4
  70. Никита
  71. 4.5
  72. 4 4 4 4
  73. Линда
  74. 5
  75. 4 5 5 5
  76. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement