Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- void sortuj(int tab[])
- {
- int i = 0;
- int j = 0;
- for(i; i < 20; i++)
- {
- for(j=i; j < 20; j++)
- {
- if(tab[j]<tab[i])
- {
- swap(tab[j], tab[i]);
- }
- }
- }
- }
- void wyswietl_tablice(int tab[])
- {
- int i = 0;
- for(i; i < 20; i++)
- {
- cout << tab[i] << " ";
- }
- }
- int main()
- {
- int tab[20];
- srand(time(NULL));
- for(int i = 0; i < 20; i++)
- {
- tab[i] = rand()%20;
- }
- wyswietl_tablice(tab);
- cout << endl;
- sortuj(tab);
- wyswietl_tablice(tab);
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement