Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <cmath>
- using namespace std;
- struct student {
- char lastName[20];
- char firstName[20];
- int sumNotes = 0;
- string scholarship;
- };
- int main()
- {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- student students[3];
- int minNotes = 20;
- for (int i = 0; i < 3; i++) {
- fin >> students[i].lastName;
- fin >> students[i].firstName;
- for (int j = 0; j < 4; j++) {
- int note;
- fin >> note;
- students[i].sumNotes += note;
- }
- getline(fin, students[i].scholarship);
- if (students[i].sumNotes < minNotes && students[i].scholarship.size() != 2)
- minNotes = students[i].sumNotes;
- }
- for (int i = 0; i < 3; i++) {
- if (students[i].scholarship.size() != 2 && students[i].sumNotes == minNotes) {
- fout << students[i].lastName << ' ' << students[i].firstName << '\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement