#include<iostream>
#include<list>
#include<algorithm>
#include<vector>


using namespace std;

class student
{
    public:
    string name;
    int roll_number;

    student(string n,int rn)
    {
        name=n;
        roll_number=rn;
    }
};

struct StudentNameIs {
   std::string key;
   StudentNameIs(const std::string& k) : key(k) {}
   bool operator()(const student& s) const { return key == s.name; }
};

void display(list<student> &s)
{
    list<student> :: iterator p;
    for(p=s.begin();p!=s.end();p++)
    cout<<p->name<<" "<<p->roll_number<<endl;
}
int main()
{
    student s1("J",63),s2("P",29),s3("M",12),s4("S",71),s5("R",04);
    list<student> student_list;

    student_list.push_back(s1);
    student_list.push_back(s2);
    student_list.push_back(s3);
    student_list.push_back(s4);
    student_list.push_back(s5);

   display(student_list);

   list<student> :: iterator q;
   string temp;
    list<student> :: iterator s,e;
    s=student_list.begin();
    e=student_list.end();
//Accepting name of the student from the user to display roll number of it.

   cout<<"Please Enter the name of student:"<<endl;
   cin>>temp;


   q=find_if(s, e, StudentNameIs(temp));

   cout<<"The number is "<<q->roll_number<<endl;
    return 0;
}
