Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- void Wpisz(int iloscslow,string tab[],string *wskaznik[])
- {
- cout<<"podaj kolejne slowa:\n";
- for(int i=0;i<40;i++)
- {
- getline(cin,tab[i]);
- wskaznik[i]=&tab[i];
- if((*wskaznik[i]).empty())
- {
- iloscslow=i+1;
- break;
- }
- }
- }
- void SortujAlfabetycznie(int iloscslow, string *wskaznik[])
- {
- for(int i=0;i<iloscslow;i++)
- {
- for(int j=0;j<iloscslow-1;j++)
- {
- if(*wskaznik[j] > *wskaznik[j+1])
- {
- swap(*wskaznik[j],*wskaznik[j+1]);
- }
- }
- }
- }
- void Wypisz(string *wskaznik[], int iloscslow)
- {
- cout<<"Te slowa w kolejnosci alfabetycznej to: \n";
- for(int i=0;i<iloscslow;i++)
- {
- cout<<*wskaznik[i]<<endl;
- }
- }
- int main()
- {
- string tab[40];
- string *wskaznik[40];
- int iloscslow=0;
- Wpisz(iloscslow, tab,wskaznik);
- SortujAlfabetycznie( iloscslow,wskaznik);
- Wypisz(wskaznik,iloscslow);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement