fork download
  1. #include <iostream>
  2. using namespace std;
  3. int a[101], b[101], c[101], d[101];
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. for (int i = 0; i < n; i++) {
  9. cin >> a[i] >> b[i] >> c[i];
  10. d[i] = a[i] * 3600 + b[i] * 60 + c[i];
  11. }
  12. for (int i = 0; i < n; i++) {
  13. for (int j = i + 1; j < n; j++) {
  14. if (d[i] > d[j]) {
  15. swap(a[i], a[j]);
  16. swap(b[i], b[j]);
  17. swap(c[i], c[j]);
  18. swap(d[i], d[j]);
  19. }
  20. }
  21. }
  22. for (int i = 0; i < n; i++) {
  23. cout << a[i] << " " << b[i] << " " << c[i] << endl;
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 15240KB
stdin
3                           
23 56 45
21 45 54 
6 45 23
stdout
6 45 23
21 45 54
23 56 45