Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<vector>
- #include<algorithm>
- using namespace std;
- class student{
- public:
- string name;
- string group;
- vector <int> points;
- student();
- student(string name_new, string group_new, vector <int> news){
- name=name_new;
- group=group_new;
- points=news;
- }
- void enter_marks(int tmp){
- points.push_back(tmp);
- }
- double average(){
- int sum=0;
- int size=points.size();
- for(auto&s:points){
- sum=+s;
- }
- double avr=(sum/size);
- return avr;
- }
- void print(){
- cout<<"name: "<<name<<"\n"<<"group: "<<group<<"\n";
- cout<<"points ";
- for(auto& s:points){
- cout<<s<<" ";
- }
- cout<<endl;
- }
- void sorted(){
- sort(begin(points), end(points));
- }
- void maximum(){
- int max=0;
- for(auto s:points){
- if (s>max){
- max=s;
- }
- }
- cout<<"maximum points: "<<max<<endl;
- }
- void count_maximum(){
- int max=0;
- for(auto s:points){
- if (s>max){
- max=s;
- }
- }
- int counter=0;
- for(auto j:points){
- if(max==j){
- ++counter;
- }
- }
- cout<<"number of maximum points: "<<counter<<endl;
- }
- };
- int main(){
- vector <int> tmp={5,5,3,4};
- student first={"name","surname",tmp};
- first.print();
- student second={"name_2","surname_2",tmp};
- second.print();
- first.sorted();
- first.print();
- first.enter_marks(3);
- first.print();
- first.maximum();
- first.count_maximum();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement