~cpp
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct student{
string name;
int score;
student()
{
}
student(string aName, int aScore) // �성� ?? !!
{
name = aName;
score = aScore;
}
};
bool comp_score(student a, student b);
bool comp_name(student a, student b);
void main()
{
student students[5] = {
student("í™©ì„ í™�",94),
student("�명보",95),
student("김태�",93),
student("최용수",87),
student("ì•ˆì •í™˜",98),
};
vector<student> vector1;
for(int i=0; i<5; i++)
vector1.push_back(students[i]);
sort(vector1.begin(), vector1.end(), comp_score);
for(i=0; i<5; i++)
cout << vector1[i].score << endl ;
sort(vector1.begin(), vector1.end(), comp_name);
for(vector<student>::iterator j=vector1.begin(); j<vector1.end(); j++)
cout << (*j).name << endl ;
}
bool comp_score(student a, student b)
{
return a.score < b.score;
}
bool comp_name(student a, student b)
{
return a.name < b.name;
}
STL실습,
ë�°ë¸”ìŠ¤ìº í”„2004/목요ì�¼