{{{~cpp #include #include #include #include #include using namespace std; struct student{string name; int score;}; bool compare(student a, student b); bool compare2(student a, student b); void main() { student st[5]; st[0].name = "build"; st[0].score = 48; st[1].name = "deb"; st[1].score = 57; st[2].name = "finde"; st[2].score = 87; st[3].name = "inew"; st[3].score = 90; st[4].name = "ilbo"; st[4].score = 82; vector stre; stre.push_back(st[0]); stre.push_back(st[1]); stre.push_back(st[2]); stre.push_back(st[3]); stre.push_back(st[4]); sort(stre.begin(), stre.end(),compare); for(vector::iterator i = stre.begin(); i!=stre.end() ;i++) cout << i->name <<"\t"<score<< endl; cout<<"-------------------------"<name <<"\t"<score<< endl; /* for(vector::iterator i = stre.begin();!(i=stre.end());i++) cout << (*i).name << endl; */ } bool compare(student a, student b) { return a.name < b.name; } bool compare2(student a, student b) { return a.score < b.score; } }}} ---- [STL실습], [데블스캠프2004/목요일]