码迷,mamicode.com
首页 > 其他好文 > 详细

CCCC训练赛一些模板 struct sstream

时间:2018-03-25 14:24:53      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:body   class   name   vector   bool   优先级队列   operator   turn   out   

重载与构造

struct node
{
friend bool operator< (node n1, node n2)
{
return n1.priority > n2.priority;//"<"为从大到小排列,">"为从小到大排列
}

int priority;
int value;
node(int priority, int value) : priority(priority), value(value) {};

};

priority_queue<node>;

//priority_queue<int, vector<int>,less<int> > qi2;//从小到大的优先级队列,可将greater改为less,即为从大到小

读入一行

 

#include<string>
using namespace std;

int main() {

string line;
while (getline(cin, line))
{
stringstream ss(line);
int x;
while(ss >> x)
cout << x;
}

 

CCCC训练赛一些模板 struct sstream

标签:body   class   name   vector   bool   优先级队列   operator   turn   out   

原文地址:https://www.cnblogs.com/SuuT/p/8644035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!