CCCC训练赛一些模板 struct sstream

时间:2021-08-10 23:55:28

重载与构造

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;
}