Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. void sorting(char[],);
  6. int main()
  7.  
  8. {
  9. int arraysize=0;
  10. char Bubble[ arraysize ];
  11.  
  12. cout << "Please enter the size of the array: " << endl;
  13. cin>>arraysize;
  14. cout<<"Please enter "<< arraysize<< " character to be sorted."<<endl;
  15. for ( int i = 0; i < arraysize; i++ )
  16.  
  17. cin >> Bubble[ i ];
  18.  
  19.  
  20. cout <<"unsorted array:\n";
  21.  
  22.  
  23. for ( int j = 0; j < arraysize; j++ )
  24. cout << Bubble[ j ]<< " ";
  25.  
  26. for(int y=0; y < arraysize; y++)
  27.  
  28. {
  29.  
  30. for ( int k =0; k < arraysize -1-y; k++ )
  31.  
  32. if(Bubble[k]>Bubble[k+1])
  33.  
  34. {
  35.  
  36. char temp = Bubble[k+1];
  37.  
  38. Bubble[k+1] = Bubble[k];
  39.  
  40. Bubble[k] = temp;
  41.  
  42. }
  43.  
  44. }
  45.  
  46.  
  47. cout << "\nSorted Bubble array:\n";
  48.  
  49. for (int l = 0; l < arraysize; l++ )
  50. cout <<Bubble[ l ]<< " ";
  51.  
  52. cout << endl;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement