Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int N;
- char (*a)[20] = new char [N][20];
- void bubb_sort(int rijec)
- {
- for (int j=0;j<strlen(a[rijec]);j++)
- {
- for (int i=0; i<strlen(a[rijec])-1; i++)
- {
- if (a[rijec][i]>a[rijec][i+1])
- {
- char pom=a[rijec][i+1];
- a[rijec][i+1]=a[rijec][i];
- a[rijec][i]=pom;
- }
- /*cout<<"-------------"<<endl;
- cout<<"i="<<i<<endl;
- cout<<"i+1="<<i+1<<endl;
- cout<<"-------------"<<endl;*/
- }
- }
- }
- int main()
- {
- do
- {
- cin>>N;
- }while(!(N<20));
- for(int i=0; i<N; i++)
- cin>>a[i];
- for (int i=0; i<N; i++)
- bubb_sort(i);
- for (int i=0; i<N; i++)
- cout<<a[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement