j4ggi

JiMP_lab8_1

Nov 17th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void bubblesort(string* tab, int rozmiar)
  6. {
  7.     for (int i=0; i<rozmiar; i++)
  8.         for (int j=0; j<rozmiar-1; j++)
  9.         {
  10.             if(tab[j].compare(tab[j+1])>0)
  11.                 swap(tab[j], tab[j+1]);
  12.         }
  13. }
  14.  
  15. int main()
  16. {
  17.     cout<<"Ile nazwisk chcesz podac?";
  18.     int n;
  19.     cin>>n;
  20.     string tab[n];
  21.     for(int i=0;i<n;i++)
  22.         cin>>tab[i];
  23.     cout<<endl<<endl;
  24.     bubblesort(tab, n);
  25.     for(int i=0;i<n;i++)
  26.         cout<<tab[i]<<"\t";
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment