Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <cstring>
- using namespace std;
- void sorting(char[],);
- int main()
- {
- int arraysize=0;
- char Bubble[ arraysize ];
- cout << "Please enter the size of the array: " << endl;
- cin>>arraysize;
- cout<<"Please enter "<< arraysize<< " character to be sorted."<<endl;
- for ( int i = 0; i < arraysize; i++ )
- cin >> Bubble[ i ];
- cout <<"unsorted array:\n";
- for ( int j = 0; j < arraysize; j++ )
- cout << Bubble[ j ]<< " ";
- for(int y=0; y < arraysize; y++)
- {
- for ( int k =0; k < arraysize -1-y; k++ )
- if(Bubble[k]>Bubble[k+1])
- {
- char temp = Bubble[k+1];
- Bubble[k+1] = Bubble[k];
- Bubble[k] = temp;
- }
- }
- cout << "\nSorted Bubble array:\n";
- for (int l = 0; l < arraysize; l++ )
- cout <<Bubble[ l ]<< " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement