Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- struct Student {
- string Imya, Faliliya, Otchestvo;
- int Kurs, Gruppa;
- double Time;
- void initialize(ifstream &in);
- string toString();
- };
- void Student::initialize(ifstream &in){
- string temp;
- in >> this->Faliliya >> this->Imya >> this->Otchestvo >> temp;
- this->Kurs = stoi(temp);
- in >> temp;
- this->Gruppa = stoi(temp);
- in >> temp;
- this->Time = stod(temp);
- }
- string Student::toString() {
- string res = this->Faliliya + " "
- + this->Imya + " "
- + this->Otchestvo + " "
- + to_string(this->Kurs) + " "
- + to_string(this->Gruppa) + " "
- + to_string(this->Time);
- return res;
- }
- bool isKeySame (Student *s, int keyValue){
- return s->Gruppa == keyValue;
- }
- int main() {
- setlocale(LC_ALL, "Russian");
- long studCount; string temp; int gruppa;
- ifstream in("input.txt");
- ofstream out("output.txt");
- if (!in) return 0; // Файл пуст
- in >> temp;
- studCount = stol(temp);
- cout << "Введите запрашиваемую группу: ";
- cin >> gruppa;
- auto students = new Student[studCount];
- for (auto s = students; s < students + studCount; s++) {
- s->initialize(in);
- if (isKeySame(s, gruppa)) {
- temp = s->toString();
- out << temp << endl;
- cout << temp << endl;
- }
- }
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement