fork(1) download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. const int SIZE = 10;
  9. // unique_ptr<char[]> noRepeats(new char);
  10. char originalArray[SIZE];
  11. originalArray [0] = 'a';
  12. originalArray [1] = 'b';
  13. originalArray [2] = 'b';
  14. originalArray [3] = 'c';
  15. originalArray [4] = 'a';
  16. originalArray [5] = 'c';
  17. originalArray [6] = 'a';
  18. originalArray [7] = 'c';
  19. originalArray [8] = 'b';
  20. originalArray [9] = 'c';
  21.  
  22. cout << "This is the original array:" << endl;
  23. for (int i = 0; i < SIZE; i++)
  24. {
  25. cout << originalArray[i] << endl;
  26. }
  27.  
  28. cout << "Now the program will run a for loop to identify dupes" << endl;
  29. for (int j = 1; j <= SIZE - 1; j++)
  30. {
  31. for (int k = j; k <= SIZE; k++)
  32. {
  33. if (originalArray[j] > originalArray[k])
  34. {
  35. swap(originalArray[j],originalArray[k]);
  36. }
  37. }
  38. }
  39. cout << "This is the sorted array:" << endl;
  40. for (int i = 0; i < SIZE; i++)
  41. {
  42. cout << originalArray[i] << endl;
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
This is the original array:
a
b
b
c
a
c
a
c
b
c
Now the program will run a for loop to identify dupes
This is the sorted array:
a
�
a
a
b
b
b
c
c
c