#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;
}
};
bool operator==(const student& lhs, const student& rhs)
{
return lhs.name == rhs.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(s, e, student(temp, 0));
cout<<"The number is "<<q->roll_number<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGxpc3Q+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8dmVjdG9yPgoKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBzdHVkZW50CnsKICAgIHB1YmxpYzoKICAgIHN0cmluZyBuYW1lOwogICAgaW50IHJvbGxfbnVtYmVyOwoKICAgIHN0dWRlbnQoc3RyaW5nIG4saW50IHJuKQogICAgewogICAgICAgIG5hbWU9bjsKICAgICAgICByb2xsX251bWJlcj1ybjsKICAgIH0KfTsKYm9vbCBvcGVyYXRvcj09KGNvbnN0IHN0dWRlbnQmIGxocywgY29uc3Qgc3R1ZGVudCYgcmhzKQp7CiAgICByZXR1cm4gbGhzLm5hbWUgPT0gcmhzLm5hbWU7Cn0KCgp2b2lkIGRpc3BsYXkobGlzdDxzdHVkZW50PiAmcykKewogICAgbGlzdDxzdHVkZW50PiA6OiBpdGVyYXRvciBwOwogICAgZm9yKHA9cy5iZWdpbigpO3AhPXMuZW5kKCk7cCsrKQogICAgY291d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