Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void bubblesort(string* tab, int rozmiar)
- {
- for (int i=0; i<rozmiar; i++)
- for (int j=0; j<rozmiar-1; j++)
- {
- if(tab[j].compare(tab[j+1])>0)
- swap(tab[j], tab[j+1]);
- }
- }
- int main()
- {
- cout<<"Ile nazwisk chcesz podac?";
- int n;
- cin>>n;
- string tab[n];
- for(int i=0;i<n;i++)
- cin>>tab[i];
- cout<<endl<<endl;
- bubblesort(tab, n);
- for(int i=0;i<n;i++)
- cout<<tab[i]<<"\t";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment