1. 程式人生 > >CCCC訓練賽一些模板 struct sstream

CCCC訓練賽一些模板 struct sstream

tor pos bool pre ngs namespace turn space while

重載與構造

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