C++ 结构体初始化
来源:互联网 发布:身份证sql判断 编辑:程序博客网 时间:2024/06/07 03:24
http://www.cnblogs.com/Vincent-Bryan/p/6622790.html
#include<bits/stdc++.h>using namespace std;struct Node{ int M, V; Node(int a, int b){ M = a; V = b; }};int main(){ Node n1(1, 65), n2(5, 23), n3(2, 99); cout << n1.M << ' ' << n1.V << endl; cout << n2.M << ' ' << n2.V << endl; cout << n3.M << ' ' << n3.V << endl;}
#include<bits/stdc++.h>using namespace std;struct Node{ int M, V; Node(int a, int b){ M = a; V = b; } friend bool operator < (const Node n1, const Node n2){ return n1.V < n2.V; } friend bool operator > (const Node n1, const Node n2){ return n1.V > n2.V; } friend ostream &operator << (ostream &os, const Node n){ os << n.M << ' ' << n.V; return os; }};int main(){ Node n1(1, 65), n2(5, 23), n3(2, 99); if(n1 < n2) cout << n1 << endl; else cout << n2 << endl;}
#include<bits/stdc++.h>using namespace std;struct Node{ int M, V; Node(int a, int b){ M = a; V = b; } friend bool operator < (const Node n1, const Node n2){ return n1.V < n2.V; } friend bool operator > (const Node n1, const Node n2){ return n1.V > n2.V; } friend ostream &operator << (ostream &os, const Node n){ os << n.M << ' ' << n.V; return os; }};int main(){ Node n1(1, 65), n2(5, 23), n3(2, 99); priority_queue<Node> pq; pq.push(n1), pq.push(n2), pq.push(n3); while(!pq.empty()){ Node n = pq.top(); pq.pop(); cout << n << endl; }}
阅读全文
0 0
- c 结构体初始化
- c结构体初始化
- c 结构体初始化
- C结构体初始化
- C/C++结构体初始化
- C语言结构体初始化
- C/C++结构体初始化
- 【C/C++】结构体de初始化
- C语言里面结构体初始化
- c语言结构体指针初始化
- Linux C中结构体初始化
- 测试一下C语言结构体初始化
- Linux C中结构体初始化
- c语言结构体指针初始化
- C语言中结构体的初始化
- c语言结构体指针初始化
- c语言结构体指针成员初始化
- c语言结构体指针初始化
- jackson工具类json转list、json转map、json转bean、bean转json
- UVA.580 Critical Mass (递推)
- 121. 单次购买股票问题
- POJ总结(2159)
- Java:利用I/O流读取文件内容
- C++ 结构体初始化
- 9. Palindrome Number
- python机器学习-数据规模统计
- 利用WHID为隔离主机建立隐秘通道
- POJ总结(3299)
- OpenCV遍历图片像素点
- MySQL多表&JDBC
- 压缩下载文件
- 【学习笔记】面试集锦【3】