Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include "datei.h"
  3. using namespace std;
  4.  
  5. int* sortArrayNew(int arrayInt[])
  6.  
  7. {
  8. bool sorted = false;
  9. int temp = 0;
  10.  
  11. static int arrayIntNew[L];
  12.  
  13. cout << "arrayInt before copy: " << endl;
  14. for (int i = 0; i < L; i++)
  15. {
  16. cout << arrayInt[i] << "\t";
  17. }
  18. cout << endl;
  19.  
  20. for (int i = 0; i < L; i++)
  21. {
  22. arrayIntNew[i] = arrayInt[i];
  23. }
  24.  
  25. cout << "arrayIntNew after copy: " << endl;
  26. for (int i = 0; i < L; i++)
  27. {
  28. cout << arrayIntNew[i] << "\t";
  29. }
  30. cout << endl;
  31.  
  32.  
  33. while(sorted == false)
  34. {
  35. sorted = true;
  36. for (int i = 0; i < L -1; i++)
  37. {
  38. if (arrayIntNew[i] > arrayIntNew[i + 1])
  39. {
  40. sorted = false;
  41. temp = arrayIntNew[i];
  42. arrayIntNew[i] = arrayIntNew[i + 1];
  43. arrayIntNew[i + 1] = temp;
  44. }
  45. }
  46. }
  47.  
  48. cout << "arrayIntNew after sort: " << endl;
  49. for (int i = 0; i < L; i++)
  50. {
  51. cout << arrayIntNew[i] << "\t";
  52. }
  53. cout << endl;
  54.  
  55. return arrayIntNew;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement