Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. class student{
  7. private:
  8. int f;
  9. string name,family;
  10.  
  11. public:
  12. student(int fac, string nam,string fam);
  13.  
  14. string get_name() const { return name; }
  15. string get_family() const { return family; }
  16. int get_f() const { return f; }
  17. void set_f(int fac) { f = fac; }
  18. void print() const{ cout<< name << " " << family
  19. << " " << f << endl; }
  20.  
  21.  
  22. };
  23. student::student(int fac, string nam,string fam)
  24. {
  25. name=nam;
  26. family=fam;
  27. f=fac;
  28. }
  29.  
  30. void print(vector<student> v)
  31. {
  32. for(int i = 0; i < v.size() ; i++)
  33. v[i].print();
  34. }
  35.  
  36. void del(vector<student>& v, int fac)
  37. {
  38. for(int i=0; i<v.size(); i++)
  39. {
  40. if(fac == v[i].get_f())
  41. for (int j=i; j<v.size()-1; j++)
  42. v[j] = v[j+1];
  43. v.pop_back();
  44. return;
  45. }
  46.  
  47. }
  48.  
  49. void add(vector<student>& v, student stud)
  50. {
  51. v.push_back(stud);
  52. }
  53.  
  54. int main()
  55. {
  56. vector<student> st;
  57. string nam,fam;
  58. int fac;
  59.  
  60. while (cin >> nam >> fam >> fac)
  61. st.push_back(student(fac,nam,fam));
  62.  
  63. print (st);
  64. del (st, 55325);
  65. cout<< endl;
  66. print (st);
  67. cout<< endl;
  68.  
  69. add(st, student(22222 ,"Alex", "Draganov"));
  70. print (st);
  71.  
  72. cout<<endl<<st[0].get_name() << " " << st[0].get_family() << endl;
  73.  
  74. st[0].set_f(99999);
  75.  
  76. cout<< endl;
  77. print (st);
  78.  
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement