Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <windows.h>
- #include <fstream>
- using namespace std;
- struct Students
- {
- string Name;
- float at;
- float sr;
- int ses[4];
- };
- int main()
- {
- float sum = 0;
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- setlocale(LC_ALL,"");
- Students gr[5];
- // for (int i = 0; i < 5; i++)
- // {
- // cout << "Имя : ";
- // cin >> gr[i].Name;
- // cout << "Средний бал за аттестат : ";
- // cin >> gr[i].at;
- // cout << "Оценки за последнюю сессию : ";
- // for (int j = 0; j < 4; j++)
- // cin >> gr[i].ses[j];
- // cout << endl;
- // }
- ifstream fin("Students.txt");
- for(int i = 0; i < 5; ++i)
- {
- fin >> gr[i].Name;
- fin >> gr[i].at;
- for (int j = 0; j < 4; j++)
- fin >> gr[i].ses[j];
- }
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 4; j++)
- {
- sum += gr[i].ses[j];
- }
- gr[i].sr = sum / 4;
- sum = 0;
- }
- cout << "Результаты в файле Result.txt\n\n";
- ofstream fout("Result.txt");
- fout << "Студенты, у которых средний балл по итогам сессии ниже среднего балла аттестата\n";
- for (int i = 0; i < 5; i++)
- {
- if (gr[i].sr < gr[i].at) fout << "Имя: " << gr[i].Name << "\n" << "Средний бал аттестата : " << gr[i].at << "\n" << "Средняя оценка за экзамен : " << gr[i].sr << "\n";
- fout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement