Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- { int l;
- cout<<"Podaj ilosc liczb do sortowania: ";
- cin>>l;
- cout << "podaj liczby" << endl;
- int *tablica= new int[l];
- for (int i=0;i<l;i++)
- {
- cin>>tablica [i];
- }
- cout<<endl;
- cout<<"sortowanie rosnaco" <<endl;
- for (int i=0;i<l-1;i++)
- {
- for(int j=0;j<l-1;j++)
- if(tablica[j]>tablica[j+1])
- {
- swap(tablica[j],tablica[j+1]);
- }
- }
- for (int i=0;i<l;i++)
- {
- cout<<tablica [i]<<endl;
- }
- cout<<endl;
- cout<<"sortowanie malejaco" <<endl;
- for (int i=0;i<l-1;i++)
- {
- for(int j=0;j<l-1;j++)
- if(tablica[j]<tablica[j+1])
- {
- swap(tablica[j],tablica[j+1]);
- }
- }
- for (int i=0;i<l;i++)
- {
- cout<<tablica [i]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement