Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void sort(char* sort_a,int num)
- {
- for(int i=0;i<num;i++)
- {
- for(int j=i+1;j<num;j++)
- {
- if(sort_a[i]>sort_a[j])
- {
- char temp;
- temp=sort_a[i];
- sort_a[i]=sort_a[j];
- sort_a[j]=temp;
- }
- }
- }
- }
- int main()
- {
- char n[5]={'s','o','n','c','i'};
- cout<<"n[] before sort: ";
- for(int i=0;i<5;i++)
- {
- cout<<n[i];
- }
- cout<<endl;
- sort(n,5);
- cout<<"after sorted:";
- for(int i=0;i<5;i++)
- {
- cout<<n[i];
- }
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement