More actions
imported>Unknown No edit summary |
(Repair batch-0005 pages from live compare) |
||
| Line 41: | Line 41: | ||
} | } | ||
---- | ---- | ||
STL실습, 데블스캠프2004/목요일 | |||
Latest revision as of 00:44, 27 March 2026
백터 연습문제
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct student
{
string name;
int score;
};
bool compare(student stu1, student stu2)
{
return stu1.score > stu2.score;
}
void main()
{
ifstream fin("input.txt");
vector <student> vec;
vector <student> ::iterator i=0;
student temp;
while(!fin.eof())
{
fin >> temp.name >> temp.score;
vec.push_back(temp);
}
sort(vec.begin(), vec.end(), *compare);
for(i=vec.begin();i<vec.end();i++)
{
cout << (*i).name << endl;
cout << (*i).score << endl;
}
}
STL실습, 데블스캠프2004/목요일