Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- string musor;
- struct Student {
- string Name;
- string Surname;
- string Fathername;
- string Pol;
- string Faculty;
- int Course;
- string Group;
- int Oc[5]; //дневник
- string Residence;
- Student() {
- }
- Student(string Name, string Surname, string Fathername, string Pol, string Faculty, int Course, string Group, int O[5], string Residence) {
- this->Name = Name;
- this->Surname = Surname;
- this->Fathername = Fathername;
- this->Pol = Pol;
- this->Faculty = Faculty;
- this->Course = Course;
- this->Group = Group;
- for (int i = 0; i < 5; i++) {
- Oc[i] = O[i];
- }
- this->Residence = Residence;
- }
- void S() {
- cout << "Имя: ";
- getline(cin, Name);
- cout << "Фамилия: ";
- getline(cin, Surname);
- cout << "Отчество: ";
- getline(cin, Fathername);
- cout << "Пол: ";
- getline(cin, Pol);
- cout << "Факультет: ";
- getline(cin, Faculty);
- cout << "Курс: ";
- cin >> Course;
- getline(cin, musor);
- cout << "Группа: ";
- getline(cin, Group);
- cout << "Оценка по предметам: " << endl;
- for (int i = 0; i < 5; i++) {
- cout << i + 1 << " предмет: ";
- cin >> Oc[i];
- }
- getline(cin, musor);
- cout << "Место жительства: ";
- getline(cin, Residence);
- }
- void Show() {
- cout << "Имя: " << Name << endl;
- cout << "Фамилия: " << Surname << endl;
- cout << "Отчество: " << Fathername << endl;
- cout << "Пол: " << Pol << endl;
- cout << "Факультет: " << Faculty << endl;
- cout << "Курс: " << Course << endl;
- cout << "Группа: " << Group << endl;
- cout << "Оценка по предметам: " << endl;;
- for (int i = 0; i < 5; i++) {
- cout << i + 1 << " предмет: " << Oc[i] << endl;
- }
- cout << "Место жительства: " << Residence << endl;
- }
- };
- int main() {
- std::setlocale(LC_CTYPE, "");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- vector <Student> Students;
- ifstream in("C:\\Users\\Никита\\Desktop\\folder\\TIMP2\\file2.txt");
- int k;
- if (in.is_open()) {
- in >> k;
- for (int i = 0; i < k; i++) {
- string Name;
- string Surname;
- string Fathername;
- string Pol;
- string Faculty;
- int Course;
- string Group;
- int Oc[5]; //дневник
- string Residence;
- in >> Name;
- in >> Surname;
- in >> Fathername;
- in >> Pol;
- in >> Faculty;
- in >> Course;
- in >> Group;
- in >> Oc[0];
- in >> Oc[1];
- in >> Oc[2];
- in >> Oc[3];
- in >> Oc[4];
- in >> Residence;
- Student s(Name, Surname, Fathername, Pol, Faculty, Course, Group, Oc, Residence);
- Students.push_back(s);
- }
- }
- in.close();
- vector <Student> D; //список задолжников
- vector <Student> F; //список обычных студентов
- for (int j = 0; j < Students.size(); j++) {
- int c = 0;
- for (int i = 0; i < 5; i++) {
- if (Students[j].Oc[i] == 0) {
- c++; //оценка 0 - задолженность
- }
- }
- if (c == 2) {
- D.push_back(Students[j]);
- }
- else {
- F.push_back(Students[j]);
- }
- c = 0;
- }
- for (int i = D.size() - 1; i > 0; i--) { //сортировка по алфавиту
- for (int j = 0; j <= i; j++) {
- if (D[j].Surname[0] > D[i].Surname[0]) {
- swap(D[j], D[i]);
- }
- }
- }
- cout << "Задолжники по 2 предметам: " << endl;
- for (int i = 0; i < D.size(); i++) {
- cout << D[i].Surname << endl;
- }
- ofstream out;
- out.open("C:\\Users\\Никита\\Desktop\\folder\\TIMP2\\file.txt");
- if (out.is_open())
- {
- out << "Задолжники по 2 предметам: " << endl;
- for (int i = 0; i < D.size(); i++) {
- out << D[i].Name << endl;
- out << D[i].Surname << endl;
- out << D[i].Fathername << endl;
- out << "Пол: " << D[i].Pol << endl;
- out << "Факультет: " << D[i].Faculty << endl;
- out << "Курс: " << D[i].Course << endl;
- out << "Группа: " << D[i].Group << endl;
- out << "Оценки: " << endl;
- for (int j = 0; j < 5; j++) {
- out << j + 1 << " предмет: " << D[i].Oc[j];
- out << endl;
- }
- out << "Адрес проживания: " << D[i].Residence << endl;
- out << endl;
- }
- out << "Другие студенты: " << endl;
- for (int i = 0; i < F.size(); i++) {
- out << F[i].Name << endl;
- out << F[i].Surname << endl;
- out << F[i].Fathername << endl;
- out << "Пол: " << F[i].Pol << endl;
- out << "Факультет: " << F[i].Faculty << endl;
- out << "Курс: " << F[i].Course << endl;
- out << "Группа: " << F[i].Group << endl;
- out << "Оценки: " << endl;
- for (int j = 0; j < 5; j++) {
- out << j + 1 << " предмет: " << F[i].Oc[j];
- out << endl;
- }
- out << "Адрес проживания: " << F[i].Residence << endl;
- out << endl;
- }
- }
- out.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement