#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;
}
};
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, [&](const student& s){return s.name == temp;});
cout<<"The number is "<<q->roll_number<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGxpc3Q+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8dmVjdG9yPgoKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBzdHVkZW50CnsKICAgIHB1YmxpYzoKICAgIHN0cmluZyBuYW1lOwogICAgaW50IHJvbGxfbnVtYmVyOwoKICAgIHN0dWRlbnQoc3RyaW5nIG4saW50IHJuKQogICAgewogICAgICAgIG5hbWU9bjsKICAgICAgICByb2xsX251bWJlcj1ybjsKICAgIH0KfTsKCnZvaWQgZGlzcGxheShsaXN0PHN0dWRlbnQ+ICZzKQp7CiAgICBsaXN0PHN0dWRlbnQ+IDo6IGl0ZXJhdG9yIHA7CiAgICBmb3IocD1zLmJlZ2luKCk7cCE9cy5lbmQoKTtwKyspCiAgICBjb3V0PDxwLT5uYW1lPDwiICI8PHAtPnJvbGxfbnVtYmVyPDxlbmRsOwp9CmludCBtYWluKCkKewogICAgc3R1ZGVudCBzMSgiSiIsNjMpLHMyKCJQIiwyOSksczMoIk0iLDEyKSxzNCgiUyIsNzEpLHM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