fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct Edge {
  5. int a,b,w;
  6. bool operator<(const Edge& y) { return w < y.w; }
  7. };
  8.  
  9. int main() {
  10. int M = 4;
  11. vector<Edge> v;
  12. for (int i = 0; i < M; ++i) {
  13. int a,b,w; cin >> a >> b >> w;
  14. v.push_back({a,b,w});
  15. }
  16. sort(begin(v),end(v));
  17. for (Edge e: v) cout << e.a << " " << e.b << " " << e.w << "\n";
  18. }
Success #stdin #stdout 0.01s 5348KB
stdin
Standard input is empty
stdout
1459488673 5375 2076803080
1459488673 5375 2076803080
1459488673 5375 2076803080
1459488673 5375 2076803080