Advertisement
Guest User

Лаба 10 2005

a guest
Apr 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. struct student {
  9. char lastName[20];
  10. char firstName[20];
  11. int sumNotes = 0;
  12. string scholarship;
  13. };
  14.  
  15. int main()
  16. {
  17. ifstream fin("input.txt");
  18. ofstream fout("output.txt");
  19. student students[3];
  20. int minNotes = 20;
  21.  
  22. for (int i = 0; i < 3; i++) {
  23. fin >> students[i].lastName;
  24. fin >> students[i].firstName;
  25.  
  26. for (int j = 0; j < 4; j++) {
  27. int note;
  28. fin >> note;
  29. students[i].sumNotes += note;
  30. }
  31.  
  32. getline(fin, students[i].scholarship);
  33.  
  34. if (students[i].sumNotes < minNotes && students[i].scholarship.size() != 2)
  35. minNotes = students[i].sumNotes;
  36. }
  37.  
  38. for (int i = 0; i < 3; i++) {
  39. if (students[i].scholarship.size() != 2 && students[i].sumNotes == minNotes) {
  40. fout << students[i].lastName << ' ' << students[i].firstName << '\n';
  41. }
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement