Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- #include <string>
- int i=1;
- using namespace std;
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- struct Student
- {
- string name;
- int bookNumber;
- string fac;
- int number;
- int estimates[5];
- public:
- void Read()
- {
- fin >> name >> bookNumber >> fac >> number;
- for (int i=0;i<5;i++)
- {
- fin >> estimates[i];
- }
- }
- void Print()
- {
- fout << name << " " << bookNumber << " " << fac << " " << number << " ";
- for (int i=0;i<5;i++)
- {
- fout << estimates[i] << " ";
- }
- fout << endl;
- }
- };
- bool cmp(Student stud)
- {
- if (stud.estimates[0]==2 || stud.estimates[1]==2 || stud.estimates[2]==2 || stud.estimates[3]==2 || stud.estimates[4]==2) return true;
- else return false;
- }
- void func(Student stud)
- {
- if (stud.estimates[0]==2 || stud.estimates[1]==2 || stud.estimates[2]==2 || stud.estimates[3]==2 || stud.estimates[4]==2)
- {
- fout << i <<" ";
- }
- i++;
- }
- int main()
- {
- int n,count=0;
- fin >> n;
- vector <Student> stud(n);
- for (int i=0;i<n;i++)
- {
- stud[i].Read();
- }
- count=count_if(stud.begin(), stud.end(), cmp);
- fout << count << endl;
- for_each(stud.begin(), stud.end(), func);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement