Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int l_elementow,i,min,pomoc,j;
- cout<<"Podaj liczbe elementow zbioru: ";
- cin>>l_elementow;
- int tablica[l_elementow];
- srand(time(NULL));
- for(i=0; i<l_elementow; i++)
- tablica[i]=rand()%98+3;
- for(i=0; i<l_elementow; i++)
- cout<<tablica[i]<<" ";
- cout<<endl;
- for(i=0; i<l_elementow; i++)
- {
- min=i;
- for(j=i+1; j<l_elementow; j++)
- {
- if(tablica[j]<tablica[min])
- min=j;
- }
- pomoc=tablica[min];
- tablica[min]=tablica[i];
- tablica[i]=pomoc;
- }
- for(i=0; i<l_elementow; i++)
- cout<<tablica[i]<<" ";
- cout<<endl<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment