Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <vector>
- using namespace std;
- class student{
- private:
- int f;
- string name,family;
- public:
- student(int fac, string nam,string fam);
- string get_name() const { return name; }
- string get_family() const { return family; }
- int get_f() const { return f; }
- void set_f(int fac) { f = fac; }
- void print() const{ cout<< name << " " << family
- << " " << f << endl; }
- };
- student::student(int fac, string nam,string fam)
- {
- name=nam;
- family=fam;
- f=fac;
- }
- void print(vector<student> v)
- {
- for(int i = 0; i < v.size() ; i++)
- v[i].print();
- }
- void del(vector<student>& v, int fac)
- {
- for(int i=0; i<v.size(); i++)
- {
- if(fac == v[i].get_f())
- for (int j=i; j<v.size()-1; j++)
- v[j] = v[j+1];
- v.pop_back();
- return;
- }
- }
- void add(vector<student>& v, student stud)
- {
- v.push_back(stud);
- }
- int main()
- {
- vector<student> st;
- string nam,fam;
- int fac;
- while (cin >> nam >> fam >> fac)
- st.push_back(student(fac,nam,fam));
- print (st);
- del (st, 55325);
- cout<< endl;
- print (st);
- cout<< endl;
- add(st, student(22222 ,"Alex", "Draganov"));
- print (st);
- cout<<endl<<st[0].get_name() << " " << st[0].get_family() << endl;
- st[0].set_f(99999);
- cout<< endl;
- print (st);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement