U E D R , A S I H C RSS

벡터/김수진

===벡터/김수진===
~cpp 
#include<iostream> 
#include<vector> 
#include<string>
#include<algorithm> 
using namespace std; 
struct student
{
	string name;
	int score;
};
bool compare(student a, student b)
{
	return a.name > b.name;
}
int main() 
{ 
	student student1, student2, student3;
	student1.name="kim";
	student2.name="lee";
	student3.name="shin";
	student1.score=100;
	student2.score=90;
	student3.score=80;
	vector< student > vec;
	vec.push_back(student1);
	vec.push_back(student2);
	vec.push_back(student3);
	sort(vec.begin(),vec.end(),compare);
	vector<student>::iterator i=vec.begin();  
	for(i=vec.begin();i!=vec.end();i++)  
		cout<<(*i).score<<endl; 

	return 0; 
} 
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:35
Processing time 0.0068 sec