Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Mając dane N tekstów.
- Napisz funkcję sortującą teksty niemalejąco (tj. alfabetycznie). Należy zastosować algorytm
- sortowania przez prostą zamianę. Implementacja optymalna. */
- #include <iostream>
- #include<stdio.h>
- #include<string>
- using namespace std;
- int const size = 10;
- void sort_babelkowe(string *tab,int size)
- {
- for (int i = 0; i< size; i++)
- {
- for (int j = 0 ;j<size -1;j++)
- {
- if (tab[j]>tab[j+1])
- swap(tab[j],tab[j+1]);
- }
- }
- }
- int main()
- {
- string tab[] = {"katowicki","nyski","augustowski","krakowski",
- "opolski","wroclawski","poznanski","krakowski",
- "randomski","katowicki"};
- cout<<"Twoja tablica :"<<endl;
- for(int i =0;i<size ;i++)
- {
- cout<<tab[i]<<" ";
- }
- cout<<endl;
- cout<<"Po sortowaniu prze proste wstawianie"<<endl;
- sort_babelkowe(tab,size);
- for(int i =0;i<size ;i++)
- {
- cout<<tab[i]<<" ";
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment