fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 100;
  5.  
  6. int main() {
  7. int idNo, totalStud, idNumbers[MAX_LENGTH + 1], logTimes[MAX_LENGTH + 1], auxArray[MAX_LENGTH + 1];
  8. cin >> idNo >> totalStud;
  9. for (int i = 1; i <= totalStud; ++i) {
  10. cin >> idNumbers[i];
  11.  
  12. }
  13.  
  14. for (int i = 1; i <= totalStud; ++i) {
  15. cin >> logTimes[i];
  16.  
  17. }
  18. int aux = 0;
  19. for (int i = 1; i < totalStud; ++i) {
  20. if (idNumbers[i] >= idNumbers[i + 1]) {
  21. aux = idNumbers[i];
  22. idNumbers[i] = idNumbers[i + 1];
  23. idNumbers[i + 1] = aux;
  24.  
  25. }
  26.  
  27. }
  28. for (int i = 1; i <= totalStud; ++i) {
  29. cout << idNumbers[i] << " ";
  30.  
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5308KB
stdin
12 7
14 1 3 3 12 5 12
8 5 3 4 5 7 19
stdout
1 3 3 12 5 12 14